Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

After all $(document).ready() have run, is there an event for that?

Tags:

jquery

I have a first.js file included in the page index.php that have something like this:

$(function(){      $("#my_slider").slider("value", 10);  }); 

And them in index.php I have some dynamicly created slidders:

<?php function slidders($config, $addon) {     $return = '     <script type="text/javascript">         $(function() {             $("#slider_'.$addon['p_cod'].'").slider({             min: '.$config['min'].',             max: '.$config['max'].',             step: '.$config['step'].',             slide: function(event, ui) {                 $("#cod_'.$addon['p_cod'].'").val(ui.value);                 $(".cod_'.$addon['p_cod'].'").html(ui.value+"'.@$unit.'");             },             change: function(event, ui) {                  $("#cod_'.$addon['p_cod'].'").change();             }         });             $("#cod_'.$addon['p_cod'].'").val($("#slider_'.$addon['p_cod'].'").slider("value"));             $(".cod_'.$addon['p_cod'].'").html($("#slider_'.$addon['p_cod'].'").slider("value")+"'.@$unit.'");     });     </script>';     return $return; } ?> 

The problem is, because my index.php sliders are being instantiated after my first.js I can't set up a value there, is there any event like "after all $(document).ready() have run" that I can use in first.js to manipulate the sliders created in index.php?

like image 793
mjsilva Avatar asked Jun 09 '10 18:06

mjsilva


People also ask

What runs after document ready?

So, there is no event called after document. ready(). You'll need to create and wait for events to complete on your own, or use window.

Does document ready only run once?

$( document ). ready()ready() will only run once the page Document Object Model (DOM) is ready for JavaScript code to execute.

Can we use ready () function more than once?

Yes we can do it as like I did in below example both the $(document). ready will get called, first come first served. In below code you will be cleared.

What is $( document ready () function Why should you use it?

The ready() method is used to make a function available after the document is loaded. Whatever code you write inside the $(document ). ready() method will run once the page DOM is ready to execute JavaScript code.


1 Answers

Dont know how to tell when the last $(document).ready() function fired, but $(window).load() function fires after the $(document).ready()

like image 148
John Hartsock Avatar answered Sep 23 '22 01:09

John Hartsock