Home › Forums › JavaScript › Jquery json using the module pattern? › Reply To: Jquery json using the module pattern?
Just glancing, you’d need to pass jQuery in. It looks like everything else you’d need are the id
s of the form elements you’re using —if so, it would probably be easiest to pass them in a single options
object (it would be easy to provide defaults this way, too).
I might suggest using classnames instead of ids, but that’s up to you. It would make it more modular/resilient. But it won’t really affect how we code it, so no big deal.
Looks like we’ll need to specify the URL for the ajax call, too.
edit:
I would highly recommend getting rid of this:
$("form").bind("keypress", function(e) {
if (e.keyCode == 13) {
return false;
}
});
Hitting [Enter] is supposed to cause a form to submit. It’s not a bug, it’s a well-established UX feature. Unless you have a really good reason*, you should not break the user’s experience by trying to control how their browser works.
* and I’ve never heard a “really good reason”