Hi all,
I am completing my integration of a jQuery component with pyjs, which I
will share with you as soon as is ready. We could add that to the examples
dir.
Currently I am trying to pass a jQuery event up to my python code. The
jQuery component is a Select2 element, which fires a change event whenever
the user changes the content. I have verified that this is working by
calling a pure javascript function, like this:
class MySelect2TaggingComponent(HTML):
...
def setup_show(self):
show = '''
function show() {
var e=parent.jQuery("<div
style='background-color:yellow;'>change
fired</div>");
parent.jQuery("#%s").append(e);
e.animate({opacity:0}, 100000, 'linear', function() {
e.remove(); });
};''' % (self.myid)
myjs = '%s parent.jQuery("#%s").bind("change", show);' % (show, self
.myid)
Logger("MySelect2TaggingComponent > setup_show", "Now calling JS:
%s" % (myjs))
JS(""" eval(@{{myjs}}) """)
As you can see here, what I am doing is to define a show function and bind
it to the element change event. This works.
Now instead of calling the javascript show function, I want to call a pyjs
"change" function, which will perform data processing and will send the
data to the server.
I would like to define a change method like this:
class MySelect2TaggingComponent(HTML):
def change(self):
...
How can I bind the javascript "change" event to this change method?
Thanks,
Daniel