#NEWLINE# def bind( self , at , element , code , * varargs ) : #NEWLINE# #INDENT# if isinstance ( code , str ) : #NEWLINE# #INDENT# fnc = self . rdoc . jsfunction ( 'vm' , 'm' , 'e' , 'i' , body = ( 'return ' + code ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# fnc = whattodo #NEWLINE# #UNINDENT# whattodo = getattr ( self , at ) #NEWLINE# params = ',' . join ( varargs ) #NEWLINE# s = '#{params}' #NEWLINE# if params : #NEWLINE# #INDENT# s = ( ',' + s ) #NEWLINE# #UNINDENT# self . rdoc . JS ( ( ( "\n            if (typeof #{element}.app == 'undefined')\n                #{element}.app = {};\n            if (typeof #{element}.app.execute_controller == 'undefined')\n                #{element}.app.execute_controller = [];\n            if (typeof #{element}.app.oldval == 'undefined')\n                #{element}.app.oldval = [];\n            #{element}.app.oldval.push(undefined);\n            #{element}.app.m = #{self.model};\n            #{element}.app.vm = #{self.viewmodel};\n            #{element}.app.execute_controller.push(\n                function(vm, m, e, j, i) {\n                    var newval = #{fnc}(vm, m, e, i);\n                    if ((#{self.ismuttable}(newval)) || (newval != e.app.oldval[j])) {\n                        #{whattodo}(vm, m, e, newval, i" + s ) + ');\n                        e.app.oldval[j] = newval;\n                    }\n                });\n        ' ) , encapsulate_strings = False )