0

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.

1

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

4 Comments

thanks for your help. However when i click on the button, no alert will show. still not working.
,/*undefined param*/, will produce ,,, that is bad right? May you use ,undefined, instead.
@PeterRader I was just pointing that out. ,"", would also work.
@PeterRader Thanks for pointing that out, I added it and moved the comment.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.