.mouseenter() doesn't work on content loaded with jQuerys .load() function
Date : March 29 2020, 07:55 AM
To fix this issue In your case use .delegate() for elements dynamically added to #workcontent, like this: $("#workcontent").delegate('.workitem', 'mouseenter', function() {
$(".webImgOverlay").fadeIn(200);
}).delegate('.workitem', 'mouseleave', function() {
$(".webImgOverlay").fadeOut(200);
});
$(".workitem").live('mouseenter', function() {
$(".webImgOverlay").fadeIn(200);
}).live('mouseleave', function() {
$(".webImgOverlay").fadeOut(200);
});
|
Load scripts after page has loaded?
Date : March 29 2020, 07:55 AM
I think the issue was by ths following , In JQuery you could do this on document ready $.getScript("somescript.js", function(){
alert("Script loaded and executed.");
});
|
scripts stop working for loaded form - jquery load ajax
Date : March 29 2020, 07:55 AM
may help you . i am using drupal and ihve successfuly loaded a node creation form using jquery load function , using Drupal.attachBehaviors() we can :) example $(id).load(url, function(){
Drupal.attachBehaviors(this);
});
|
When using .load() to change a divs content do I need to re-include my scripts?
Date : March 29 2020, 07:55 AM
I wish this help you When you load elements dynamically, you need to use jQuery's .on() function to bind events to the elements that are loaded. You need to bind with .on() to an element that already exists in the DOM and usually the worst case scenario for that is the body element. If you be more specific than body you'll usually get improved performance. For example, if you loaded a table row into a table and wanted to bind the click event on the new row, you'd use: $("table").on("click", "tr", function(event){
//do something
});
|
Load scripts if not already loaded, and then use them
Date : March 29 2020, 07:55 AM
hop of those help? I think your problem is because myapp_init() is executed before scripts are loaded You need to manage script load event and after call myapp_init() some like this inside each if() condition: var myapp_script;
var scripts_loaded = 0;
if (!window.jQuery) {
myapp_script = document.createElement('script');
document.body.appendChild(myapp_script);
myapp_script.src = 'http://myapp.dev/js/jquery.min.js';
console.log('load jquery');
myapp_script.onload = function(){
scripts_loaded ++;
if(scripts_loaded === 4){ //4 because in your example you have 4 scripts to load
myapp_init();
}
}
}else{
scripts_loaded ++;
}
//...
//And so on with others if conditions
|