I'm having trouble using the event.preventDefault(); for an ahref on my DOM

后端 未结 4 795
[愿得一人]
[愿得一人] 2021-02-09 13:09

I\'m having trouble using the event.preventDefault(); for an ahref on my DOM.

How do you prevent the url from posting a nofollow delete, as spe

4条回答
  •  故里飘歌
    2021-02-09 13:48

    I faced the same issue, but failed to get any good solution after breaking my head for hours. So, based on the suggested answers here, I did something like:

    function enableLink() {
      jQuery("#link_id").removeClass("disabled");
      jQuery("#link_id").attr("data-remote", true);
    }
    
    
    function disableLink() {
      jQuery("#link_id").addClass("disabled");
      jQuery("#link_id").removeAttr("data-remote");
    }
    
    jQuery(document).ready(function(){
      jQuery(document).on("click", "disabled", function(e){
        e.preventDefault();
      });
    });
    

    I accept it's not a good workaround. But, thats what helped me.

提交回复
热议问题