That`s why you have a callback for ajax functions. AJAX stands for *asynchronous* Javascript and XML. That means the ajax call doesn't wait for the answer to return. It fires the call, returns the XHR object and the script goes on. When something is returned, the callback function is fired, and in there you must handle the data.
function paint() { $("#mid").load("paint.htm", function(){ $('#colorpicker').farbtastic('#color'); }); }; Check the docs for more information (docs.jquery.com/Ajax) cheers, -ricardo On Dec 29, 7:27 pm, BlueStunt <l...@lsdon.com> wrote: > I'm a complete newbie to jQuery and am trying to use farbtastic (a jquery > colour picker) > > The documentation suggests calling the function on document load: > > <script type="text/javascript"> > $(document).ready(function() { > $('#colorpicker').farbtastic('#color'); > }); > </script> > > However I am loading the associated elements: > > <form> > <input type="text" id="color" name="color" value="#123456" /> > </form> > <div id="colorpicker"> > </div> > > from an html file using: > > function paint() { > $("#mid").load("paint.htm");} > > </script> > > How would I then go about executing > > $('#colorpicker').farbtastic('#color'); > > I've already tried numerous incantations such as: > > function paint() { > $("#mid").load("paint.htm"), > $('#colorpicker').farbtastic('#color'); > > } > > but I just can't seem to get it to work. > > Help will be very much appreciated =) > -- > View this message in > context:http://www.nabble.com/Calling-functions-tp21209391s27240p21209391.html > Sent from the jQuery General Discussion mailing list archive at Nabble.com. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "jQuery (English)" group. To post to this group, send email to jquery-en@googlegroups.com To unsubscribe from this group, send email to jquery-en+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/jquery-en?hl=en -~----------~----~----~----~------~----~------~--~---