Welcome Guest, Not a member yet? Register   Sign In
Trying to get jQuery/Ajax to work with CI
#8

[eluser]ggoforth[/eluser]
[quote author="slowgary" date="1246224293"]Hmmm... so the above doesn't work? It looks okay. The bind command is just a more generalized way to attach event handlers. These are functionally equivalent:
Code:
.bind('click', function(){
});
.click(function(){
});
And so are these:
Code:
.bind('submit', function(){
});
.submit(function(){
});
But in either case, as long as you pass that anonymous function an identifier for the event, you should be able to call the preventDefault() method on that event like so:
Code:
.submit(function(e){
     e.preventDefault();
});
And preventDefault() is not even a jQuery method, it's native JavaScript so it should work in any modern browser. Do you have this code live anywhere for examination?[/quote]

I have always used return(false); inside my submit functions, but I prefer to attach them to an id, so something like:

Code:
$('#my_form_id').submit(function(){
   //do something
   return(false);
});
This works for me, but I don't use the other methods much, so I wouldn't know what to tell you about those.

Greg


Messages In This Thread
Trying to get jQuery/Ajax to work with CI - by El Forum - 06-27-2009, 01:45 AM
Trying to get jQuery/Ajax to work with CI - by El Forum - 06-27-2009, 12:05 PM
Trying to get jQuery/Ajax to work with CI - by El Forum - 06-27-2009, 09:06 PM
Trying to get jQuery/Ajax to work with CI - by El Forum - 06-27-2009, 10:24 PM
Trying to get jQuery/Ajax to work with CI - by El Forum - 06-27-2009, 10:30 PM
Trying to get jQuery/Ajax to work with CI - by El Forum - 06-28-2009, 02:29 AM
Trying to get jQuery/Ajax to work with CI - by El Forum - 06-28-2009, 10:24 AM
Trying to get jQuery/Ajax to work with CI - by El Forum - 06-28-2009, 09:23 PM



Theme © iAndrew 2016 - Forum software by © MyBB