Hello all, this is my first posting, although I've been watching you for some
time :)
I'm trying to develope a small piece for dynamic loading in jquery, wich
loads the .js and .css source files on the fly without any special markup in
the html page. Probably you've seen this before (dojo.require and siimilar)
The problem is that it seems that the browser doesn't wait until the script
(the plugin) is finished loading, and give errors when I try to use it.
For example, in $(document).ready( ...
jQuery.require('jquery.accordion');
$('#myaccordion').Accordion();
gives an error, but later, if I try the 2nd line in firebug, the plugin
works as expected. I've tried in Firefox 2 and IE7 with same results. I know
that is a problem with the synchronism, but I don't know how to resolve it.
here is the code:
(function(jq){
jq.extend({
require: function(plugin, o){
o = jq.extend({
css: false,
jsbase: '',
cssbase: '',
wait: true
}, o || {});
var src = o.jsbase + '/' + plugin + '.js';
jq.getScript(src);
// here it should wait, but how?
if(o.css){
var c = document.createElement('link');
c.type = 'text/css';
c.rel = 'stylesheet';
c.href = o.cssbase + '/' + plugin + '.css';
jq('head')[0].appendChild(c);
}
}
});
})(jQuery);
Any ideas?
Thanks in advance.
Jip
--
View this message in context:
http://www.nabble.com/dynamic-plugin-loading-tf2889880.html#a8073485
Sent from the JQuery mailing list archive at Nabble.com.
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/