I'm building a couple of widgets that I want provide the ability for
other js functions to be called when something happens. For example:
when a widget is hidden or show.... I thought I understood how to use
the js_function but maybe not.
in my update_params calls of one of the widgets, I have something
like this...
self.add_call("setupModalContainer('%s',{onOpen:%s,onClose:
%s,onShow:%s});" % (self.id,self.js_on_open or
'undefined',self.js_on_close or 'undefined',self.js_on_show or
'undefined'))
where js_on_open and js_on_close are other js functions. Everything
seems to work fine on the client side for this and I basically get js
rendered on the client like....
function setupModalContainer('modal-1',{OnOpen:function(){alert
('hi');},OnClose:undefined});
i have another widget that I wanted to use the same idea except that
it can contain many widgets so the function needs to look like
this.....
function setupTabbedContainer('tabbed-container-1','tab-1',{
'tab-1':{OnActivate:function(){alert
('hi');},OnDeactivate:undefined},
'tab-2':{OnActivate:undefined,OnDeActivate:undefined}
}
);
so in my update_params for this I use a slightly different
strategy....
tab_events={}
for t in self.tabs:
tab_events[t.id]=dict(onActivate=t.js_on_activate or
'undefined',onDeactivate=t.js_on_deactivate or 'undefined')
.............
self.add_call(self.js_setup(self.id,d
['active_tab'],tab_events))
it seems that if there are no callbacks from the tabs collection
(results in all undefined...) everything works fine, but no callback
events. if I put a js_function object on a tab though, I get a json
serializable error..
Any ideas on what the trick is here, or any references to resources
that may shed some light on how to do things like this? my google-fu
didn't turn up much....
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"ToscaWidgets-discuss" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/toscawidgets-discuss?hl=en
-~----------~----~----~----~------~----~------~--~---