Solved

reload the page without refreshing???

Posted on 2011-02-25
4
270 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
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…

749 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