Skip to content

Commit cb47c62

Browse files
author
hartsantler
committed
core: can not call javascript functions using keyword arguments they are converted to a JavaScript Object, if dict or list is passed to a js function - they are auto converted to Array and Object.
1 parent 95ea574 commit cb47c62

6 files changed

Lines changed: 392 additions & 350 deletions

File tree

README.rst

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,33 @@ are also returned directly, like document.body. This allows
384384
you to use the HTML DOM API just as you would in normal
385385
JavaScript.
386386

387+
If the JavaScript function you are calling takes a JavaScript
388+
Object as the last argument you can call the function using
389+
keyword arguments and they will be automatically converted
390+
to a JavaScript Object. Any dictionaries or lists you pass
391+
to a JavaScript function will be converted to: Array or Object.
392+
393+
Example::
394+
395+
<script type="text/javascript">
396+
397+
function js_function( a,b,c, options ) {
398+
console.log('abc', a,b,c);
399+
console.log( c[0] ); // mylist was automatically converted to an Array
400+
console.log( c[1] );
401+
return options.x + options.y + options.z;
402+
}
403+
404+
</script>
405+
406+
<script type="text/python">
407+
408+
def test():
409+
mylist = ['hello', 'world']
410+
print js_function( 'A','B', mylist, x=1, y=2, z=3 )
411+
412+
</script>
413+
387414
---------------
388415

389416
Inline JavaScript

0 commit comments

Comments
 (0)