Hi C Anthony.

I only want to illustrate callback from javascript to python method.

For example:
original method:

    def bind_pyjs_change(self):
        # This is supposed to bind the change event to the change pyjs function
        # Since we are binding a global function to the self.change method, we 
want
        #   that global function to be unique (or at least to have the myid 
suffix)
        global_unique_change = "change_%s" % (self.myid)
        wnd().global_unique_change = self.change
        # Now bind the change event to the wnd().global_unique_change function, 
which is actually self.change
        myjs = 'parent.jQuery("#%s").bind("change", function() { parent.%s() 
});' % (self.myid, global_unique_change)
        log.info("Now calling JS: %s", myjs)

        JS(""" eval(@{{myjs}}) """)




can be replaced with this version:

def bind_pyjs_change(self):
    id = "#%s" % self.myid
    JS("""parent.jQuery(@{{id}}).bind("change", function() { 
@{{self}}.change() });""")


Without making global unique vars.

Bye.


>

-- 



Reply via email to