Welcome Guest, Not a member yet? Register   Sign In
How to Submit textarea comment on Enter key?
#3

[eluser]Prullenbak[/eluser]
This is not really CodeIgniter related, but more a jquery thing...

You could try if this works:

Code:
$("#commentbox").keyup(function(event) {

    if (event.which == 13) {
        event.preventDefault();
        alert("Submit!");

        $("#commentForm").submit();
    }
});

Basically, you forgot the '#' signs to tell jQuery to look for an ID, and the keypress handler (which I changed to a keyup..I read somewhere that's better for several reasons...Don't know if that's true, but it also doesn't hurt Tongue ) should be assigned to the commentbox, instead of the commentForm id.

Also, make sure this code is in your documents ready() function, like this:

Code:
$(document).ready(function(){

//code from above in here.

});



Messages In This Thread
How to Submit textarea comment on Enter key? - by El Forum - 01-08-2013, 08:25 PM
How to Submit textarea comment on Enter key? - by El Forum - 01-08-2013, 11:16 PM
How to Submit textarea comment on Enter key? - by El Forum - 01-09-2013, 03:16 AM
How to Submit textarea comment on Enter key? - by El Forum - 01-09-2013, 04:55 AM
How to Submit textarea comment on Enter key? - by El Forum - 01-09-2013, 08:00 AM
How to Submit textarea comment on Enter key? - by El Forum - 01-09-2013, 08:08 AM
How to Submit textarea comment on Enter key? - by El Forum - 01-09-2013, 08:40 AM
How to Submit textarea comment on Enter key? - by El Forum - 01-09-2013, 08:46 AM
How to Submit textarea comment on Enter key? - by El Forum - 01-09-2013, 09:29 AM
How to Submit textarea comment on Enter key? - by El Forum - 01-10-2013, 12:57 AM
How to Submit textarea comment on Enter key? - by El Forum - 01-10-2013, 04:16 AM
How to Submit textarea comment on Enter key? - by El Forum - 01-10-2013, 05:57 AM
How to Submit textarea comment on Enter key? - by El Forum - 01-10-2013, 09:01 AM



Theme © iAndrew 2016 - Forum software by © MyBB