Note that there are some explanatory texts on larger screens.

plurals
  1. POjQuery .load() with scripts
    primarykey
    data
    text
    <p>I know this question has been asked but I haven't found any satisfactory answers. I have a very simple html page that I want to load into a number of other pages. That's no problem but where I'm getting stuck is that this html page has one jQuery hover function that simply will not execute on the other pages. I've tried putting the hover function on each page, I've tried .getScript. From what I understand, jQuery will load the scripts from the .load() page, execute them, then remove them. But since it's a hover function I need those scripts to stay around. Is there any way I can do this? I'll post the code if necessary but it works perfectly so I don't think it's that...</p> <p>on each page:</p> <pre><code> if ($("#zz7_Menu:contains('myname')")) { $("#toolbar").load('toolbar.html table.toolbaradmin'); } else { $("#toolbar").load('/toolbar.html table.toolbar'); } </code></pre> <p>toolbar.html:</p> <pre><code>&lt;script type="text/javascript" src="scripts/jquery-1.6.2.min.js"&gt;&lt;/script&gt; &lt;link rel="stylesheet" href="jquery-ui/css/redmond/jquery-ui-1.8.13.custom.css" type="text/css" media="all" /&gt; &lt;script&gt; $(document).ready(function() { $('.ui-state-default').hover(function() { $(this).removeClass('ui-state-default').addClass('ui-state-hover'); }, function() { $(this).removeClass('ui-state-hover').addClass('ui-state-default'); }); }); &lt;/script&gt; &lt;table class="toolbar"&gt; &lt;tr&gt; &lt;td class="ui-state-default ui-corner-all toolbar"&gt; </code></pre> <p>etc...</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.
 

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