Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How to Run jQuery Code After Other Scripts Are Done

Posted on 2010-09-17
4
Medium Priority
?
648 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:
Gurvinder Pal Singh earned 1500 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Introduction HyperText Transfer Protocol (http://www.ietf.org/rfc/rfc2616.txt) or "HTTP" is the underpinning of internet communication.  As a teacher of web development I have heard many questions, mostly from my younger students who have come to t…
Introduction JSON is an acronym for JavaScript Object Notation.  It is a text-string data transport mechanism, capable of representing simple or complex data structures in a consistent and easy-to-read manner.  Similar in concept to XML, but more e…
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)
Suggested Courses

704 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