Solved

How to Run jQuery Code After Other Scripts Are Done

Posted on 2010-09-17
4
643 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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

Introduction Got endorsements from your clients?  Great!  There is almost nothing better than word-of-mouth advertising.  But how can you do that on the internet?  Sure you can make a page for endorsement quotations and list them all, but who is …
Introduction If you're like most people, you have occasionally made a typographical error when you're entering information into an online form.  And to your consternation, the browser remembers the error, and offers to autocomplete your future entr…
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)

803 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