[IPython-dev] Regarding Javascript rendering inside IPython notebooks

Matthias BUSSONNIER bussonniermatthias@gmail....
Mon Jun 3 07:23:02 CDT 2013


Hi, 

Le 3 juin 2013 à 12:36, TARUN GABA a écrit :

> HI,
> 
> As the part of a project, I require to embed a button inside a Javascript display.
> I have appended the button using Jquery ($()), but it is unable to produce the onClick target, which is a function which is defined inside the same Javascript data, which is being rendered.

>     $mydiv.append("<button style=\"margin-top:2px;margin-left:2px;\" onClick=\"reset();\">Reset</button>


>     function reset(){ ....
>      };


Not totally sure but 
>  onClick=\"reset();\"
is refering to a global reset and 
reset might have a smaller scope.


Try

var reset = function(){…}

var $mybutton = $('<div/>')
				.attr('style','…')
				.click(reset)
$mydiv.append($mybutton)

-- 
Matthias




More information about the IPython-dev mailing list