Skip to main content
Community Advisor
Aug 2, 2017 8:24 PM UTC
Solved

{{form.NotYou}} link actions

I'm having an issue where, when you click 'not you' it refreshes the page .... the form I am using is at the BOTTOM, so it's quite a bit of scrolling to back to where you were. Is there any way to control it, whether it's an anchor, or preventing the page from refreshing and just refreshing the form with a new cookie, or what are my options? Anyone have experience doing this?

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
SanfordWhiteman
SanfordWhitemanAccepted solution
User Group Leader
Aug 3, 2017 10:07 PM UTC

Me-oh-my this is unpretty, and I feel dirty even touching jQuery, but it should work:

MktoForms2.whenReady(function(form){

  var jQuery = MktoForms2.$,

      formEl = form.getFormElem()[0],

      notYou = formEl.querySelector('.mktoNotYou');

  if (notYou) {

    var originalHandler = jQuery._data(notYou).events.click[0].handler;

    jQuery(notYou).off("click");

    notYou.addEventListener("click",function(e){

       document.location.hash = formEl.id;

       originalHandler();

    });

   

  }

});

3 replies

Josh_Hill13
Level 10
Aug 3, 2017 8:02 PM UTC

would you send a sample or URL?

Translate
JDNelson1Community AdvisorAuthor
Community Advisor
Aug 3, 2017 9:23 PM UTC

Thanks Josh,

There's a form at the bottom of this page that we're re-doing; but want to build in the ability to 'not you' to the bottom at the same time.

https://www.spigit.com/spigit-for-ceo/

Translate
SanfordWhiteman
User Group Leader
SanfordWhitemanUser Group LeaderAccepted solution
User Group Leader
Aug 3, 2017 10:07 PM UTC

Me-oh-my this is unpretty, and I feel dirty even touching jQuery, but it should work:

MktoForms2.whenReady(function(form){

  var jQuery = MktoForms2.$,

      formEl = form.getFormElem()[0],

      notYou = formEl.querySelector('.mktoNotYou');

  if (notYou) {

    var originalHandler = jQuery._data(notYou).events.click[0].handler;

    jQuery(notYou).off("click");

    notYou.addEventListener("click",function(e){

       document.location.hash = formEl.id;

       originalHandler();

    });

   

  }

});

Translate