move js_ajax to Ext

master
inpos 2018-08-16 19:31:35 +03:00
parent 0e18a1c406
commit d2d387be45
2 changed files with 6 additions and 14 deletions

View File

@ -3,13 +3,14 @@ from . import js
__all__ = ['create', 'createByAlias', 'Component']
def js_ajax(fn, arg_dict = {}):
def js_ajax(fn, arg_dict = {}, f_type=js.js_procedure):
i = id(fn)
js.live_methods[i] = fn
func_args = ', '.join(['\'{k}\': {v}'.format( k = k,v = js.encode(v) ) for k,v in arg_dict.items()])
if func_args != '': func_args = ', ' + func_args
return "%s({'url': '%s', 'method': 'GET', 'params': { 'fn': %d, 'id_': %s %s}, 'success': %s })"\
% (js.client.Ext.Ajax.request, js.AJAX_URL, i, js.client.this.id, func_args, js.function('eval(arguments[0].responseText);'))
func_args = ',\n'.join(['\'{k}\': {v}'.format( k = k,v = js.encode(v) ) for k,v in arg_dict.items()])
if func_args != '':
func_args = ',\n' + func_args
print(func_args)
return f_type(i, ajax_args=func_args)
js.js_ajax = js_ajax

View File

@ -52,15 +52,6 @@ def js_function(func_id, ajax_args=''):
ajax_args
)
def js_ajax(fn, arg_dict = {}, f_type=js_procedure):
i = id(fn)
live_methods[i] = fn
func_args = ',\n'.join(['\'{k}\': {v}'.format( k = k,v = encode(v) ) for k,v in arg_dict.items()])
if func_args != '':
func_args = ',\n' + func_args
print(func_args)
return f_type(i, ajax_args=func_args)
def list2extjs(l):
return '[ %s ]' % ', '.join([encode(v) for v in l])