Note that there are some explanatory texts on larger screens.

plurals
  1. POOdd javascript Error (using jQuery)
    primarykey
    data
    text
    <p>I have a code that grabs the buttons click and then vanishes the actual content and makes the content of the clicked item appear. I have it running along with other thins in an init.js file that is I have:</p> <pre><code>$(function() { $('#contacto').fancybox({ 'hideOnContentClick': false, 'frameWidth': 600, 'frameHeight': 550, 'centerOnScroll': true }); $('ul.drawers').accordion({ header: 'H2.drawer-handle', selectedClass: 'open', event: 'mouseover' }); $("#about-button").css({ opacity: 0.3 }); $("#contact-button").css({ opacity: 0.3 }); $("#page-wrap div.button").click(function(){ clicked = $(this); console.log(clicked); // if the button is not already "transformed" AND is not animated if ((clicked.css("opacity") != "1") &amp;&amp; (clicked.is(":not(animated)"))) { clicked.animate({ opacity: 1, borderWidth: 5 }, 600 ); // each button div MUST have a "xx-button" and the target div must have an id "xx" var idToLoad = clicked.attr("id").split('-'); //we search trough the content for the visible div and we fade it out $("#menu-content").find("div:visible").fadeOut("fast", function(){ //once the fade out is completed, we start to fade in the right div $(this).parent().find("#"+idToLoad[0]).fadeIn(); }) } //we reset the other buttons to default style clicked.siblings(".button").animate({ opacity: 0.5, borderWidth: 1 }, 600 ); }); }); </code></pre> <p>but only the 2nd $(function() is the one that executes during this event. The HTML code that answers to this is:</p> <pre><code>&lt;div id="page-wrap"&gt; &lt;div id="festival-button" class="button"&gt; &lt;h2 class="header-ultimo-festival"&gt;&amp;Uacute;timo Festival&lt;/h2&gt; &lt;/div&gt; &lt;div id="cursos-button" class="button"&gt; &lt;h2 class="header-cursos"&gt;Cursos del A&amp;ntilde;o&lt;/h2&gt; &lt;/div&gt; &lt;div id="viajes-button" class="button"&gt; &lt;h2 class="header-viajes"&gt;Viajes del A&amp;ntilde;o&lt;/h2&gt; &lt;/div&gt; &lt;div class="clear"&gt;&lt;/div&gt; &lt;div id="menu-content"&gt; &lt;div id="festival"&gt; &lt;p&gt; &lt;a href="assets/img/varias/album/festival/plant1.jpg" title="Imagen 1" class="thickbox" rel="ultimo-festival"&gt; &lt;img src="assets/img/varias/album/festival/plant1_t.jpg" alt="Imagen 1" /&gt; &lt;/a&gt; &lt;a href="assets/img/varias/album/festival/plant2.jpg" title="Imagen 2" class="thickbox" rel="ultimo-festival"&gt; &lt;img src="assets/img/varias/album/festival/plant2_t.jpg" alt="Imagen 2" /&gt; &lt;/a&gt; &lt;a href="assets/img/varias/album/festival/plant3.jpg" title="Imagen 3" class="thickbox" rel="ultimo-festival"&gt; &lt;img src="assets/img/varias/album/festival/plant3_t.jpg" alt="Imagen 3" /&gt; &lt;/a&gt; &lt;a href="assets/img/varias/album/festival/plant4.jpg" title="Imagen 4" class="thickbox" rel="ultimo-festival"&gt; &lt;img src="assets/img/varias/album/festival/plant4_t.jpg" alt="Imagen 4" /&gt; &lt;/a&gt; &lt;/p&gt; &lt;/div&gt; &lt;div id="cursos"&gt; &lt;p&gt;Im&amp;aacute;genes de Cursos aqu&amp;iacute;&lt;/p&gt; &lt;/div&gt; &lt;div id="viajes"&gt; &lt;p&gt;Im&amp;aacute;genes de Viajes aqu&amp;iacute;&lt;/p&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>The issue is, when someone clicks on a link from my menu and activates the "fancybox" effect and afterwards tries to click on an item related to the 2nd $(function() event I get this error: </p> <blockquote> <p>$clicked.css is not a function (?)()()album.html (ligne 24) ready()()jquery.min.js (ligne 26) trigger()()jquery.min.js (ligne 25) [Break on this error] if (($clicked.css("opacity") != "1") &amp;&amp; ($clicked.is(":not(animated)"))) {</p> </blockquote> <p>But I still don't know why...I have tried to fix it but I can't because according to me I have correct syntax =/</p> <hr> <p><strong>Edit 2 answer</strong></p> <p>I did what was suggested if I click it before calling the "fancybox" effect I get in the alert box an [object Object] afterwards I get [object HTMLDivElement] and the same error as well...</p> <hr> <p><strong>Edit</strong></p> <p>By using firebug and console.log(); I noticed something, if I click before calling the "fancybox" I get back:</p> <pre><code>Object 0=div#cursos-button.button length=1 jquery=1.2.6 </code></pre> <p>But after having called it I get:</p> <pre><code>&lt;div id="cursos-button" class="button" style="border-width: 1px; opacity: 0.5;"&gt; </code></pre> <p>Now trying to figure out why...</p> <hr> <p><strong>Edit</strong></p> <p>I still don't know why this happens however I fixed it using jQuery.noConflict(); anyway, if someone do knows why this happened, I'd appreciate if you tell me =)</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload