Solved

How to Run jQuery Code After Other Scripts Are Done

Posted on 2010-09-17
4
640 Views
Last Modified: 2012-08-13
I have a jQuery plugin that I wrote that resizes some Telerik controls. The problem is that Telerik runs some JavaScript after the DOM is ready, and my jQuery runs before Telerik's script.

Is there a way I can ensure that my plugin code will run only after other scripts have fired?
0
Comment
Question by:hehdaddy
  • 2
4 Comments
 
LVL 13

Expert Comment

by:darren-w-
ID: 33704009
place your scripts after the other ones,  or use document ready method detailed here http://docs.jquery.com/Tutorials:Introducing_$%28document%29.ready%28%29
0
 
LVL 40

Accepted Solution

by:
gurvinder372 earned 500 total points
ID: 33704889
if the Telerik's scripts are plugin, then they will be fired as soon as they are arrived and compiled on browser's client. That is how plug-ins works, they get executed by themselves.

You can setup a flag, or some condition to be checked,  before loading jquery programmatically if you want.
http://ajaxpatterns.org/On-Demand_Javascript
http://ntt.cc/2008/02/10/4-ways-to-dynamically-load-external-javascriptwith-source.html
http://www.javascriptkit.com/javatutors/loadjavascriptcss.shtml
0
 
LVL 6

Author Comment

by:hehdaddy
ID: 33707194
Thanks for the great information. I ended up with a temporary hack until I can find a real solution that will be maintainable. I just set a JavaScript timeout for 200ms, which seemed to do the trick. Not ideal, but I moved on.

@gurvinder372 - I am awarding you points for your multiple links.
@darren-w- - I wasn't able to make your solution work, and I was already using $(document).ready()
0
 
LVL 6

Author Closing Comment

by:hehdaddy
ID: 33707195
He gave it a good go. I had to take a different route temporarily, but he deserved points for the informational links.
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

What is a Lightbox? A Lightbox is the effect you see when you click, for example, an image and the screen fades out and up pops the same image but in its full size dimensions. There are lots of Lightbox effects for jQuery. Problem is they are a…
Introduction Chart.js, used properly, can visually add a difference to your charting applications. It engages your visitors and allows them to interact with data they otherwise wouldn't be able to without expensive and complicated systems. For this…
The viewer will learn how to dynamically set the form action using jQuery.
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)

708 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now