Solved

How to Run jQuery Code After Other Scripts Are Done

Posted on 2010-09-17
4
647 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
[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
  • 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

Secure Your WordPress Site: 5 Essential Approaches

WordPress is the web's most popular CMS, but its dominance also makes it a target for attackers. Our eBook will show you how to:

Prevent costly exploits of core and plugin vulnerabilities
Repel automated attacks
Lock down your dashboard, secure your code, and protect your users

Question has a verified solution.

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

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 A frequently asked question goes something like this:  "I am running a long process in the background and I want to alert my client when the process finishes.  How can I send a message to the browser?"  Unfortunately, the short answer…
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

617 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