renderTo
parent
1caa69e2e4
commit
3286b15441
|
@ -17,7 +17,7 @@ class MyApplication(cp.ExtApplication):
|
|||
'items': [{'xtype': 'button', 'text': 'Click Here', 'handler': button_click}],
|
||||
'buttons': [
|
||||
{'text': 'OK', 'handler': js.FuncWithParams(ok_click, {'arg1': 1, 'arg2': 'val2'})},
|
||||
{'text': 'Close', 'handler': js.function('this.up(\'window\').close()')}]})
|
||||
{'text': 'Close', 'handler': str(js.function('this.up(\'window\').close()'))}]})
|
||||
wnd.show()
|
||||
wnd.setHeight(200)
|
||||
|
||||
|
|
|
@ -59,5 +59,5 @@ class Component(js.JsObject):
|
|||
pass
|
||||
|
||||
def __str__(self):
|
||||
s = json.dumps(self._js, default=js._encoder)
|
||||
return re.sub(r'(":\s+)("(function[^"]+)")', r'\1\3', s)
|
||||
s = json.dumps(self._js, default=js._encoder, indent=4)
|
||||
return re.sub(r'("(handler|renderTo)":\s+)("([^"]+)")', r'\1\4', s)
|
||||
|
|
|
@ -19,9 +19,9 @@ def _encoder(o):
|
|||
elif isinstance(o, JsNode):
|
||||
return block(str(o))
|
||||
elif isinstance(o, types.FunctionType) and js_ajax:
|
||||
return function(js_ajax(o))
|
||||
return str(function(js_ajax(o)))
|
||||
elif isinstance(o, FuncWithParams):
|
||||
return function(js_ajax(o.func, o.params))
|
||||
return str(function(js_ajax(o.func, o.params)))
|
||||
|
||||
def encode(o):
|
||||
if isinstance(o, JsNode):
|
||||
|
@ -34,7 +34,7 @@ def encode(o):
|
|||
# trick json serialize javascript block
|
||||
class JsBlock(str):
|
||||
def __new__(cls, *args, **kwargs):
|
||||
obj = super(JsBlock, cls).__new__(cls, 'function () { %s }' % args[0])
|
||||
obj = super(JsBlock, cls).__new__(cls, '%s' % args[0])
|
||||
obj.code = args[0]
|
||||
return obj
|
||||
|
||||
|
|
Loading…
Reference in New Issue