jquery function to prevent input from blank field with keypress of <enter>

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

jquery function to prevent input from blank field with keypress of <enter>

fugee ohu

var submit_messages;

$(document).on('turbolinks:load', function () {
    submit_messages()
})

submit_messages = function () {
    $('#message_content').on('keyDown', function (event) {
        if (event.keyCode === 13) {
            $('input').click()
            event.target.value = ''
            event.preventDefault()
            console.log('yes we hit enter!')
        }
        
    })
    
}

I got this from a youtube video titled Rails 6 - Real Time Chat App What doesn't make sense to me is why do we only clear the field if the enter key is pressed, why doesn't that work anyway (it doesn't clear the field) and why doesn't it log to console 'yes we hit enter!'

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/5c7f7223-915d-4960-89ad-5f3bd030568b%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: jquery function to prevent input from blank field with keypress of <enter>

Ariel Juodziukynas
Do you see any error on the browser's console? first thing I notice just simple looking at it is it's missing all the ; at the end of the lines, maybe you have a syntax error on the browser's dev tools

El mar., 15 oct. 2019 a las 11:35, fugee ohu (<[hidden email]>) escribió:

var submit_messages;

$(document).on('turbolinks:load', function () {
    submit_messages()
})

submit_messages = function () {
    $('#message_content').on('keyDown', function (event) {
        if (event.keyCode === 13) {
            $('input').click()
            event.target.value = ''
            event.preventDefault()
            console.log('yes we hit enter!')
        }
        
    })
    
}

I got this from a youtube video titled Rails 6 - Real Time Chat App What doesn't make sense to me is why do we only clear the field if the enter key is pressed, why doesn't that work anyway (it doesn't clear the field) and why doesn't it log to console 'yes we hit enter!'

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/5c7f7223-915d-4960-89ad-5f3bd030568b%40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAPS3bcAh0xpy848Ctr3SwEYCiv38%3DhYg1Y18_twseNmaK89Rfw%40mail.gmail.com.
Reply | Threaded
Open this post in threaded view
|

Re: jquery function to prevent input from blank field with keypress of <enter>

fugee ohu


On Tuesday, October 15, 2019 at 11:08:27 AM UTC-4, Ariel Juodziukynas wrote:
Do you see any error on the browser's console? first thing I notice just simple looking at it is it's missing all the ; at the end of the lines, maybe you have a syntax error on the browser's dev tools

El mar., 15 oct. 2019 a las 11:35, fugee ohu (<<a href="javascript:" target="_blank" gdf-obfuscated-mailto="WBMbkRQLCgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">fuge...@...>) escribió:

var submit_messages;

$(document).on('turbolinks:load', function () {
    submit_messages()
})

submit_messages = function () {
    $('#message_content').on('keyDown', function (event) {
        if (event.keyCode === 13) {
            $('input').click()
            event.target.value = ''
            event.preventDefault()
            console.log('yes we hit enter!')
        }
        
    })
    
}

I got this from a youtube video titled Rails 6 - Real Time Chat App What doesn't make sense to me is why do we only clear the field if the enter key is pressed, why doesn't that work anyway (it doesn't clear the field) and why doesn't it log to console 'yes we hit enter!'

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="WBMbkRQLCgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">rubyonra...@googlegroups.com.
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/rubyonrails-talk/5c7f7223-915d-4960-89ad-5f3bd030568b%40googlegroups.com?utm_medium=email&amp;utm_source=footer" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/rubyonrails-talk/5c7f7223-915d-4960-89ad-5f3bd030568b%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/rubyonrails-talk/5c7f7223-915d-4960-89ad-5f3bd030568b%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;">https://groups.google.com/d/msgid/rubyonrails-talk/5c7f7223-915d-4960-89ad-5f3bd030568b%40googlegroups.com.

Sorry I just needed to  restart my browser After, I deleted my question because it works in firefox and chrome too Can you please delete

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/788c142e-e2e9-43d3-a755-af38923f247d%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: jquery function to prevent input from blank field with keypress of <enter>

fugee ohu
In reply to this post by Ariel Juodziukynas


On Tuesday, October 15, 2019 at 11:08:27 AM UTC-4, Ariel Juodziukynas wrote:
Do you see any error on the browser's console? first thing I notice just simple looking at it is it's missing all the ; at the end of the lines, maybe you have a syntax error on the browser's dev tools

El mar., 15 oct. 2019 a las 11:35, fugee ohu (<<a href="javascript:" target="_blank" gdf-obfuscated-mailto="WBMbkRQLCgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">fuge...@...>) escribió:

var submit_messages;

$(document).on('turbolinks:load', function () {
    submit_messages()
})

submit_messages = function () {
    $('#message_content').on('keyDown', function (event) {
        if (event.keyCode === 13) {
            $('input').click()
            event.target.value = ''
            event.preventDefault()
            console.log('yes we hit enter!')
        }
        
    })
    
}

I got this from a youtube video titled Rails 6 - Real Time Chat App What doesn't make sense to me is why do we only clear the field if the enter key is pressed, why doesn't that work anyway (it doesn't clear the field) and why doesn't it log to console 'yes we hit enter!'

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="WBMbkRQLCgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">rubyonra...@googlegroups.com.
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/rubyonrails-talk/5c7f7223-915d-4960-89ad-5f3bd030568b%40googlegroups.com?utm_medium=email&amp;utm_source=footer" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/rubyonrails-talk/5c7f7223-915d-4960-89ad-5f3bd030568b%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/rubyonrails-talk/5c7f7223-915d-4960-89ad-5f3bd030568b%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;">https://groups.google.com/d/msgid/rubyonrails-talk/5c7f7223-915d-4960-89ad-5f3bd030568b%40googlegroups.com.

Now rails complains i'm not using a password for my database after changing to mysql2 from sqlite

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/d9031660-73d8-46c2-829d-dd49e900e3b2%40googlegroups.com.