Reputation: 1151
so I have a form wuth a button. On click i need to use to run some google analytics code (_gap.push). This wasnt working so I have decided to do an alert to do some test. The alert showing the word "outside" works however the alert showing the word "inside" is not working. So that means that it is not going into that function
Js code
applyRegisterNewUserListener: function() {
alert ("outside")
// Form that attempts to register users
$(document).on('submit', 'form#signup-form', function() {
alert ("inside"
_gaq.push(['_trackEvent', 'register', 'account', 'form',, false]);
})
},
html
<form method="post" id="#signup-form">
<input type="submit" value="submit">
</form>
I really cannot understand what is the problem. The function is being called too.
Upvotes: 0
Views: 54
Reputation: 94429
The #
sign should not be in the id
for the form markup.
<form method="post" id="signup-form">
There is also a syntax error in this section of the code.
$(document).on('submit', '#signup-form', function(event) {
event.preventDefault(); //do not submit form
alert ("inside"); // alert is missing );
_gaq.push(['_trackEvent', 'register', 'account',
'form',"", false]); //replace undefined param
}); //add ;
I'm not sure this code needs to be in listener
function. It could simply be included as a regular script since it will not execute until the submit event is fired.
Upvotes: 2