We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
  • discuss.answer
    • 28042 ☆ A M B ☆
    • 24,524 Posts
    It's in your Javascript. The javascript that pops up the modal has to also prevent the default function of the <a> tag (which is to go to the URL).

    This question has been answered by sottwell. See the first response.

      Studying MODX in the desert - http://sottwell.com
      Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
      Join the Slack Community - http://modx.org
      • 48586
      • 78 Posts
      Can my modal div go inside the chunk? My snippet is creating an array that is calling the hidden fields, like year2_price and year3_price that I would like to populate the modal content, so basically my chunk would look like:

      <div class="assurance-link"><a href="#price-assurance-modal" class="open-modal">[[+pricing_message]]</a></div>
      .
      .
      .
      <div id="price-assurance-modal" class="price-assurance-modal mfp-hide">
      <div class="block">
        <div class="year">Year Two</div>
        <div class="price">[[+year2_price]]</div>
        <div class="per-month">per mo.*</div>
      </div>
      <div class="block">
        <div class="year">Year Three</div>
        <div class="price">[[+year3_price]]</div>
        <div class="per-month">per mo.*</div>
      </div>


      I've tried the preventDefault on clicks in my javascript, even tried the basic onclick return false, but those aren't working. I want to make sure that I have my modal code in the correct place, and that it will pull the data from the correct database row.
        • 28042 ☆ A M B ☆
        • 24,524 Posts
        Exactly how and where the preventDefault occurs will depend on what Javasript library or plugin you are using.

        http://api.jquery.com/event.preventdefault/
        http://stackoverflow.com/questions/19172084/plain-javascript-version-of-e-preventdefault




          Studying MODX in the desert - http://sottwell.com
          Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
          Join the Slack Community - http://modx.org
          • 48586
          • 78 Posts
          Thank you very much @sottwell, that did fix my issue with getting the modal to work, but it took a little longer to fix. There was also a jQuery conflict preventing my modal from working. I really appreciate the help.