Search code examples
javascriptruby-on-railsstoppropagation

How to get links to work when using stopPropagation on parent div


I have a modal popup with several links inside that have the :confirm and :method => :delete options. The problem is I am using stopPropagation to prevent the modal from closing when a user clicks inside the div content area.

event.stopPropagation();

However, this disables any of the javascript that Rails uses for the links that have :remote => true or :confirm or :method.

Does anyone know a workaround to this problem?

Thanks!!


Solution

  • you could get the url from the link's href attribute and set it to the window's location href attribute... It'l look something like this:

    var linkUrl = document.querySelector("a#IdOfTheLinkYouWant").href;
    window.location.href = linkUrl;