Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Paul Stewart 50 posts 71 karma points
    Apr 17, 2012 @ 11:30
    Paul Stewart
    0

    JQuery After Submit, Show Alert Box

    Hey guys, I have a client that wants to have track the number of submissions using "adTracking" which to me why? why not use google analytics, but anyway! 

    My problem is I can track the clicks of the ".contourButton" class, but I can't track the number of page submissions. 

    just like on your basic RenderForm.ascx from umbracoContour, Im wanting to control when the placeholder with the thank you message 

    RenderForm.ascx (snipplet)

    <asp:PlaceHolder ID="ph_messageOnSubmit" runat="server" Visible="false">
    <div class="showThankYou">
    <h2 class="contourMessageOnSubmit">
        <asp:Literal ID="lt_message" runat="server" Visible="false" /><umbraco:Item field="#Thank You" runat="server" />   
    </h2>
    <p><umbraco:Item field="#Our Representive" runat="server" /></p>
    </div>
    </asp:PlaceHolder>

     

    JQuery snipplet

    <script type="text/javascript" src="https://track.adform.net/serving/scripts/trackpoint"></script>
    <script>
    jQuery(document).ready(function ({
       jQuery(".contourSubmit").click(function ({
             Adform.Tracking.Track(653101130909'');
                  });
       jQuery('.contourSubmit').submit(function ({
             if(jQuery(this).valid(){
                  alert("form was submitted")
             }
        });
    });
    adf.track(653101130908);
    </script>

    Mean I've tried different alternatives, but my knowledge of jQuery is quite limited. mean for the time being if i can get the alert box to display when the form is submitted then I will be happy as larry and I can do what I need to do with the rest.

    If someone change help me I would be most highly grateful! 

    Regards
    Paul

  • Grant Thomas 291 posts 324 karma points
    Apr 17, 2012 @ 11:57
    Grant Thomas
    0

    The problem would be in subscribing to the `submit` event of the input (button), you should hook this event up to the `form` as per the jQuery documentation; I'm not sure how Contour works with what version of Umbraco you're using, but with 4.7.1.1 it doesn't generate it's own form - so this might not work for you. But if it does, and you're using a validation framework with a generic way of checking for valid submissions then you could essentially just have one 'global' validation routine for submit on the (or a named) `form` tag.

    Other than that, if hooking into the form won't do it for you, you could possibly try validating within the `click` event and simply use `e.preventDefault()` if invalid (you would need to add the `e` parameter argument to the even function.)

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies