?
Solved

reload the page without refreshing???

Posted on 2011-02-25
4
Medium Priority
?
272 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 2000 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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?
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
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…
Suggested Courses

801 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