Note that there are some explanatory texts on larger screens.

plurals
  1. POJQuery .wrap is triggering .ready a second time
    primarykey
    data
    text
    <p>For the first time ever I've not been able to find an answer to a question here. So, I'm sure I'll need to take a noob lashing, but here goes:</p> <p>For IE7/8 only, I'm trying to wrap a div around my main container which will be used to render a fake shadow(glow filter). The problem is, this causes all other jQuery blocks in that container to run again. Maybe I could use .one() somehow, or maybe I'm thinking about this wrong. Thanks for any help!</p> <p>code:</p> <pre><code>&lt;body&gt; &lt;script type="text/javascript"&gt;var hasRun = false;&lt;/script&gt; &lt;script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.js"&gt;&lt;/script&gt; &lt;div id="wrapper"&gt; &lt;script type="text/javascript"&gt; $(function(){ if(hasRun){return;} $("#wrapper").wrap("&lt;div&gt;&lt;/div&gt;"); console.log("ran block 1"); }); &lt;/script&gt; &lt;script type="text/javascript"&gt; $(function(){ // SLIDESHOW 1 if(hasRun){return;} console.log("ran block 2"); }); &lt;/script&gt; &lt;script type="text/javascript"&gt; $(function(){ // SLIDESHOW 2 if(hasRun){return;} console.log("ran block 3"); hasRun = true; }); &lt;/script&gt; &lt;/div&gt; &lt;/body&gt; </code></pre> <p>Ideally I can take the boolean out of the equation and handle this in one function...</p> <p>Maybe this would clarify my intent:</p> <pre><code>&lt;body&gt; &lt;script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.js"&gt;&lt;/script&gt; &lt;div id="wrapper"&gt; &lt;script type="text/javascript"&gt; $(function(){ if(!$.support.opacity){$("#wrapper").wrap("&lt;div&gt;&lt;/div&gt;");} console.log("ran block 1"); }); &lt;/script&gt; &lt;script type="text/javascript"&gt; $(function(){ // SLIDESHOW 1 console.log("ran block 2"); }); &lt;/script&gt; &lt;script type="text/javascript"&gt; $(function(){ // SLIDESHOW 2 console.log("ran block 3"); }); &lt;/script&gt; &lt;/div&gt; &lt;/body&gt; </code></pre> <p>What is the best way to have IE 7/8 run ALL these jQuery blocks only once?</p>
    singulars
    1. This table or related slice is empty.
    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.
 

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