Make jQuery elements execute after they been loaded in (after finish page-load)
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
events may be triggered. When you use an additional custom event for initializing, e.g. “reload”:
/*! -- ui-slider -- */ $(document).on('ready reload',function() { $( "#slider" ).slider({ range: true, min: 0, max: 500, values: [ 25, 450 ], slide: function( event, ui ) { $( "#value" ).val( "" + ui.values[ 0 ] + " - " + ui.values[ 1 ] ); } }); $( "#value" ).val( "" + $( "#slider" ).slider( "values", 0 ) + " - " + $( "#slider" ).slider( "values", 1 ) ); }); /*! -- toggleclass -- */ $(document).on('ready reload',function() { $("#div3").on('click', '.toggle', function () { $(this).toggleClass("toggle_background"); }); });….then you only need to trigger the reload-event inside the callback of
$.load()$(document).ready(function(){ $("#selectbox").change(function(){ var selectedOption = $('#selectbox :selected').val(); $containerDiv = $('#receive_content'); $containerDiv.html(""); switch (selectedOption) { case "Selectbox":$containerDiv.load( "default" , function(){$(document).trigger('reload');} ); break; case "Option 1":$containerDiv.load( "content.html #div1" , function(){$(document).trigger('reload');}); break; case "Option 2":$containerDiv.load( "content.html #div2" , function(){$(document).trigger('reload');}); break; case "Option 3":$containerDiv.load( "content.html #div3" , function(){$(document).trigger('reload');}); break; } return true; }); });