Error $ A Rel*=facebox .facebox Is Not A Function
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site facebox jquery demo About Us Learn more about Stack Overflow the company Business Learn more
Facebox Popup
about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss jquery lightbox Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Bug with jquery .on and facebox up vote 0 down vote favorite I have an element that loads from AJAX. With tthat element, I attached Facebox.js. When the element is clicked, it will triggered Facebox. So I used: $(document).on("click", "a[rel*=modal]", function() { $(this).facebox(); // Applies modal window to any link with attribute rel="modal" }); The thing is, it requires the element to be clicked twice before Facebox is triggered. So as a quick fix, I added: $('a[rel*=modal]').trigger('click'); This way, I can click the element only once to trigger. Is there a better way to fix ? jquery facebox jquery-on share|improve this question asked Sep 27 '13 at 2:51 Erwin Kaddy 917612 add a comment| 1 Answer 1 active oldest votes up vote 1 down vote accepted The problem is when the first click happens the facebox plugin is not initialized, a workaround is to initialize the plugin and then re-trigger the click event again $(document).one("click", "a[rel*=modal]", function() { $(this).facebox().triggerHandler('click'); }); share|improve this answer answered Sep 27 '13 at 2:54 Arun P Johny 270k38280329 Thank you Arun. This is exactly what I'm looking for. I happen to encounter same issues when using Jquery on with other plugins. It looks like your answer can apply to them too. –Erwin Kaddy Sep 27 '13 at 10:43 add a comment| Your Answer draft saved draft discarded Sign up or log in Sign up using Google Sign up using Facebook Sign up using Email and Password Post as a guest Name Email Post as a guest Name Email discard By posting you
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges http://stackoverflow.com/questions/19041941/bug-with-jquery-on-and-facebox Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up facebox not working after $.post up vote -1 down vote favorite i'm using facebox http://stackoverflow.com/questions/29548447/facebox-not-working-after-post to open a remote page, i includedjQuery, facebox.js and facebox.css and put it in document.ready like this jQuery(document).ready(function ($) { $('a[rel*=facebox]').facebox({ loadingImage: 'imgs/loading.gif', closeImage: 'imgs/closelabel.png' }); }); everything works till i call this function function lecFunc(year) { var name = year + '_lec'; $.post('php/scripts/lecClickScript.php', { matYear: year, matType: name }, function (data) { document.getElementById("lecs_tbody").innerHTML = data; document.getElementById("lecs_boxbody").style.display = 'block'; document.getElementById("qus_boxbody").style.display = 'none'; }); } the facebox doesn't work any more EDIT :: Solved Actully the problem was that i was using two jQuery versions then i read this qustion Can-i-use-multiple-versions-of-jquery-on-the-same-page then added this code by the exact sequence scriptvar $j = jQuery.noConflict(true); script $(document).ready(function () { console.log($().jquery); // This prints v2.1.3 console.log($j().jquery); // This prints v1.4.2 }); and in onClick.js file jQuery(document).ready(function ($) { $('a[rel*=facebox]').facebo
perfect but it works pretty well. This post shows a basic example and the html for a page skeleton which uses Facebox. I'm posting this now because I'll have some http://www.electrictoolbox.com/jquery-facebox-basic-example/ additional posts in the next few days using Facebox (and also some older ones here here and here). Download Facebox Download the Facebox plugin and associated files from http://defunkt.io/facebox/ There are a number of examples on that page but here I present a full HTML skeleton for you to start with. Download jQuery from http://jquery.com/ Working example Click me to see my logo pop open into a Facebox window. If error $ you are reading this in a feed reader then clicking that link is just going to open the logo in a browser so click through to view this page in a web browser and then click the link. The example uses a default install of Facebox with the paths changed (see note below) and my fix to make the box auto-center correctly. The HTML skeleton The following skeleton is what you error $ a need to be able to load content into Facebox boxes: