Solved

reload the page without refreshing???

Posted on 2011-02-25
4
268 Views
Last Modified: 2012-05-11
Hi all,

I've got some javascript on the $(document).ready(function(){  ... so what page ls loaded.

I have a variable which is changed at runtime ... now depending on the value of this variable some div's are loaded or not.

How can I make the call the $(document).ready(function(){ at runtime please ... or if it cannot be done... how can I do this please?

thanks


0
Comment
Question by:error77
  • 3
4 Comments
 
LVL 40

Expert Comment

by:gurvinder372
ID: 34978205
if you are loading the div with an ajax response, you can then use the callback handler of that ajax call
0
 
LVL 40

Expert Comment

by:gurvinder372
ID: 34978216
<<How can I make the call the $(document).ready(function(){ at runtime please ... or if it cannot be done... how can I do this please?>>
document.ready is called by itself. Its basically a event handler which is invoked when the page is loaded.

But why do you want to call this document.ready at run-time at first place?
0
 

Author Comment

by:error77
ID: 34978236
Ref: But why do you want to call this document.ready at run-time at first place? ... I have some code that runs on $(document).ready(function(){ and I basically want to run it again because I'm changing things at runtime

For example, I have:

IF (thisvariable==0) {
  $('#myDiv1').hide();
} else {
    $('#myDiv1').show();
}

Now... when I change "thisvariable" value at runtime, I need to re-run the code so changes are made acordingly...know what I mean?

Thanks

0
 
LVL 40

Accepted Solution

by:
gurvinder372 earned 500 total points
ID: 34978359
you can encapsulate/refactor the code inside into a method and call that method whenever you want to

$(document).ready(function(){

 ///what ever is here put that in a method, say docReady()
});

function docReady()
{
 //put all document ready code here
}


now you can call docReady whenever you want to
0

Featured Post

Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article discusses how to create an extensible mechanism for linked drop downs.
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question