On Tue, 2012-07-03 at 16:25 +0200, Łukasz Mach wrote: > W dniu 03.07.2012 08:40, Daniel Gonzalez pisze: > > > Hello, > > > > > > I am trying to integrate a jQuery component with pyjs. My code looks > > like this: > > > > > > from __pyjamas__ import JS > > > > ... > > > > > > class CallDetails(VerticalPanel): > > > > > > > > def __init__(self, avatar_image, call_from, start_date, duration, > > own_style = 'activity-call-details'): > > VerticalPanel.__init__(self) > > ... (initialization of my vertical panel, with lots of > > components, and a div with id #aa10) > > self.final_setup() > > > > > > def final_setup(self): > > JS("""jQuery("#aa10").select2({tags:["red", "green", > > "blue"]});""") > > > > > > The javascript console is telling me: > > > > > > Uncaught ReferenceError: jQuery is not defined > > > > > > > > But I have included jQuery. This is my Activity.html: > > I think it's because your "javascript compiled python code" is > included into iframe, so there is no jQuery in iframe. > > I would try to do eityher > from __javascript__ import window > window.parent.jQuery("#aa10") #I'm not sure if it will work > > or JS(""" window.parent.jQuery(...... """) >
If this works, you might also do: from __pyjamas__ import wnd wnd().parent.jQuery(...) (there's also a 'doc' defined in __pyjamas__ that refers to the js document)