I am having a strange issue, I have code that pulls content of wordpress posts that was using some plugin to bind fancybox to certain elements on the page. But now I want to implement that fancybox binding from some elements on that page.
1 | <a class="fancybox">some code here</a> |
I tried one solution for this that after binding fancybox, I removed the ‘fancybox’ class from the anchor tag. But removing class from the anchor tag in not working becoz dom collects all the elements before loading, even though i have removed the class that anchor is still being called in fancybox.
1 2 3 4 5 | <a id="noFancy" class="fancybox">some code here</a> $(document).ready(function(){ $('#noFancy').removeClass('fancybox'); }) |
I can try with unbinding click event but I need the click event to work further with that.
Then I found a solution after some googling that if you include the attribute live:false then you will be able to remove the handlers from your elements using .off()
1 2 3 4 5 6 7 | $(document).ready(function(){ $(".fancybox").fancybox({live: false}); //remove click handler $('.fancybox').off("click.fb-start"); }) |
Means we need to set the fancybox attribut live:false and then remove the ‘click.fb-start’ handler from the element.By this way I can disable fancybox after binding.
If you are facing any issue regarding fancybox as well as colorbox then post us your query. We will try to provide you a solution as soon as possible.