Steve Kim
Steve Kim

Reputation: 5591

Applying condition in jQuery

So, I have following jquery:

jQuery(document).ready(function() { 
    jQuery.ias().on('rendered', function(items) {       
        first_function();
        second_function();              
    }); 
}); 

In this current setup, the functions are only fired when jquery.ias() is rendered.

How do I change the condition so that these functions are fired both when page is loaded AND when jQuery.ias is rendered?

Thanks.

EDIT:

So, I actually have lots of functions that needs to be fired under the conditions mentioned above. Sorry for confusion

jQuery(document).ready(function() { 
    jQuery.ias().on('rendered', function(items) {       

    //1st function
    jQuery('#rh_post_add_done').click(function(){
      jQuery('#rh_post_add_done_click').click();
    }); 
    //2nd function
    jQuery(document).ready(function(){
        jQuery(".rh_setting_button").click(function(){
         var post_id_edit = jQuery(this).data("post_id");
             jQuery('#rh_' + post_id_edit).popup();
        });   
     })
     //3st function  
     //4th function
     //5th function
     //6th function
     //7th function, you get the point                  
    }); 
 });

Upvotes: 0

Views: 71

Answers (2)

Domain
Domain

Reputation: 11808

use following statement.So functions will call on both condition.

 jQuery(document).ready(function() { 
            first_function();
            second_function(); 
        jQuery.ias().on('rendered', function(items) {       
            first_function();
            second_function();              
        }); 
    });

Upvotes: 1

Yuriy Yakym
Yuriy Yakym

Reputation: 3911

jQuery(document).ready(function() { 
    jQuery.ias().on('rendered', function(items) {       
        first_function();
        second_function();              
    }); 

    first_function();
    second_function();  
});

Upvotes: 3

Related Questions