[IPython-dev] Regarding Javascript rendering inside IPython notebooks

TARUN GABA tarun.gaba7@gmail....
Tue Jun 4 02:36:24 CDT 2013


    HI, I tried this ....

    container.show();
    var $mydiv = $("<div/>").attr("id", "#container");
    var test_var=10;
    var reset = function(){ test_var=12; console.log("inside the
function");}


    $mydiv.attr("style","background-color:rgb(104,104,104)
margin-top:30px;margin-left:40px;");
    $mydiv.append("<p style=\"margin-left:10px;margin-top:20px;\">variable=
"+test_var);

    var $mybutton =
$('<button/>').click(reset).attr("style","margin-top:20px;margin-left:80px;");
    $mydiv.append($mybutton);

    element.append($mydiv);


    the console shows that we are getting inside the function, but how can
I refresh the js to show the new value of the variable, in the
   $mydiv.append("<p style=\"margin-left:10px;margin-top:20px;\">variable=
"+test_var);
part?

Thanks


On Mon, Jun 3, 2013 at 10:30 PM, <ipython-dev-request@scipy.org> wrote:

> Send IPython-dev mailing list submissions to
>         ipython-dev@scipy.org
>
> To subscribe or unsubscribe via the World Wide Web, visit
>         http://mail.scipy.org/mailman/listinfo/ipython-dev
> or, via email, send a message with subject or body 'help' to
>         ipython-dev-request@scipy.org
>
> You can reach the person managing the list at
>         ipython-dev-owner@scipy.org
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of IPython-dev digest..."
>
>
> Today's Topics:
>
>    1. Interactive SVG is not interactive in a notebook (Benjamin Root)
>    2. Re: Interactive SVG is not interactive in a notebook
>       (Benjamin Root)
>    3. Re: Interactive SVG is not interactive in a notebook
>       (Matthias BUSSONNIER)
>    4. Regarding Javascript rendering inside IPython     notebooks
>       (TARUN GABA)
>    5. Re: Regarding Javascript rendering inside IPython notebooks
>       (Matthias BUSSONNIER)
>    6. Re: Interactive SVG is not interactive in a notebook
>       (Benjamin Root)
>    7. Re: Interactive SVG is not interactive in a notebook
>       (Matthias BUSSONNIER)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Sun, 2 Jun 2013 18:29:24 -0400
> From: Benjamin Root <ben.root@ou.edu>
> Subject: [IPython-dev] Interactive SVG is not interactive in a
>         notebook
> To: IPython Development list <ipython-dev@scipy.org>
> Message-ID:
>         <CANNq6Fm5KRZ=
> NWJV4eT8bf_n3SPBU49yc6qYqhTa2HFpcEgQYA@mail.gmail.com>
> Content-Type: text/plain; charset="iso-8859-1"
>
> I am putting together a tutorial for scipy2013. I made an interactive SVG
> file that displays the parts of an mpl plot, and it works great when loaded
> up directly in a browser. However, if I display it as an embedded image, it
> acts like a static image.  I have tried embedding via markdown, HTML, and
> IPython.display.SVG to no avail.  Is something blocking the events, or
> maybe the browser isn't seeing the XML data?
>
> Thoughts?
> Ben Root
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL:
> http://mail.scipy.org/pipermail/ipython-dev/attachments/20130602/cf4df5c9/attachment-0001.html
>
> ------------------------------
>
> Message: 2
> Date: Sun, 2 Jun 2013 18:43:45 -0400
> From: Benjamin Root <ben.root@ou.edu>
> Subject: Re: [IPython-dev] Interactive SVG is not interactive in a
>         notebook
> To: IPython Development list <ipython-dev@scipy.org>
> Message-ID:
>         <CANNq6F=
> BinJ2UP9Qcx-YitxKFcnrXOgty5puMEnw4Xxy6roZaQ@mail.gmail.com>
> Content-Type: text/plain; charset="iso-8859-1"
>
> Digging further, I see that the xml data is making it to the browser, but
> the javascript embedded within the svg file is completely stripped out.  Is
> that on purpose?  Is there a way I can override that behavior?
>
> Cheers!
> Ben Root
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL:
> http://mail.scipy.org/pipermail/ipython-dev/attachments/20130602/37206764/attachment-0001.html
>
> ------------------------------
>
> Message: 3
> Date: Mon, 3 Jun 2013 08:58:59 +0200
> From: Matthias BUSSONNIER <bussonniermatthias@gmail.com>
> Subject: Re: [IPython-dev] Interactive SVG is not interactive in a
>         notebook
> To: IPython developers list <ipython-dev@scipy.org>
> Message-ID: <E825BE06-DEDA-4C37-96AF-5185699C09CA@gmail.com>
> Content-Type: text/plain; charset=iso-8859-1
>
> Hi ben,
> Le 3 juin 2013 ? 00:43, Benjamin Root a ?crit :
>
> > Digging further, I see that the xml data is making it to the browser,
> but the javascript embedded within the svg file is completely stripped out.
>  Is that on purpose?  Is there a way I can override that behavior?
>
> No we don't strip js out of XML by intent (yet). Have you try to use HTML
> that itself contain a script tag, and an svg  tag with an ID so that you
> can refer to it ?
> --
> Matthias
>
>
>
>
> ------------------------------
>
> Message: 4
> Date: Mon, 3 Jun 2013 16:06:01 +0530
> From: TARUN GABA <tarun.gaba7@gmail.com>
> Subject: [IPython-dev] Regarding Javascript rendering inside IPython
>         notebooks
> To: ipython-dev@scipy.org
> Message-ID:
>         <CAHAono14Ex5hzOruheSmTte4ea6k2ueKmZ1BYqMUSOaHkoJ=_
> Q@mail.gmail.com>
> Content-Type: text/plain; charset="iso-8859-1"
>
> 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.
>
> Code Snippet:
>
>    container.show();
>     var $mydiv = $("<div/>").attr("id", "div");
>
>     $mydiv.empty();
>     $mydiv.attr("style","background-color:rgb(104,104,104)");
>     $mydiv.append("<button style=\"margin-top:2px;margin-left:2px;\"
> onClick=\"reset();\">Reset</button>
>     element.append($mydiv);
>     function reset(){ ....
>
>      };
>
>
> Anything I might be doing incorrectly?
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL:
> http://mail.scipy.org/pipermail/ipython-dev/attachments/20130603/4207ff6a/attachment-0001.html
>
> ------------------------------
>
> Message: 5
> Date: Mon, 3 Jun 2013 14:23:02 +0200
> From: Matthias BUSSONNIER <bussonniermatthias@gmail.com>
> Subject: Re: [IPython-dev] Regarding Javascript rendering inside
>         IPython notebooks
> To: IPython developers list <ipython-dev@scipy.org>
> Message-ID: <433B3485-0C18-48D3-861F-D994C8D9F74F@gmail.com>
> Content-Type: text/plain; charset=windows-1252
>
> 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
>
>
>
>
> ------------------------------
>
> Message: 6
> Date: Mon, 3 Jun 2013 09:31:09 -0400
> From: Benjamin Root <ben.root@ou.edu>
> Subject: Re: [IPython-dev] Interactive SVG is not interactive in a
>         notebook
> To: IPython developers list <ipython-dev@scipy.org>
> Message-ID:
>         <CANNq6FnffChvbYpm-ZSG9o=
> jAbO0BZLouNZFXv62PbdrGEEioQ@mail.gmail.com>
> Content-Type: text/plain; charset="iso-8859-1"
>
> On Mon, Jun 3, 2013 at 2:58 AM, Matthias BUSSONNIER <
> bussonniermatthias@gmail.com> wrote:
>
> > Hi ben,
> > Le 3 juin 2013 ? 00:43, Benjamin Root a ?crit :
> >
> > > Digging further, I see that the xml data is making it to the browser,
> > but the javascript embedded within the svg file is completely stripped
> out.
> >  Is that on purpose?  Is there a way I can override that behavior?
> >
> > No we don't strip js out of XML by intent (yet). Have you try to use HTML
> > that itself contain a script tag, and an svg  tag with an ID so that you
> > can refer to it ?
> >
>
> Well, something is stripping it out, between the call to
> IPython.display.SVG() and what Firefox tells me it sees.  Since I need this
> to work for the tutorial, I am just going to have to assume that this is a
> bug somewhere and go for the embedded HTML approach that you suggest, since
> most of those at the tutorial would have this bug.
>
> Cheers!
> Ben Root
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL:
> http://mail.scipy.org/pipermail/ipython-dev/attachments/20130603/54b0f069/attachment-0001.html
>
> ------------------------------
>
> Message: 7
> Date: Mon, 3 Jun 2013 16:58:44 +0200
> From: Matthias BUSSONNIER <bussonniermatthias@gmail.com>
> Subject: Re: [IPython-dev] Interactive SVG is not interactive in a
>         notebook
> To: IPython developers list <ipython-dev@scipy.org>
> Message-ID: <AA0AB54A-A855-451B-A3DE-9E38DDA82C90@gmail.com>
> Content-Type: text/plain; charset="iso-8859-1"
>
>
> Le 3 juin 2013 ? 15:31, Benjamin Root a ?crit :
>
> >
> > On Mon, Jun 3, 2013 at 2:58 AM, Matthias BUSSONNIER <
> bussonniermatthias@gmail.com> wrote:
> > Hi ben,
> > Le 3 juin 2013 ? 00:43, Benjamin Root a ?crit :
> >
> > > Digging further, I see that the xml data is making it to the browser,
> but the javascript embedded within the svg file is completely stripped out.
>  Is that on purpose?  Is there a way I can override that behavior?
> >
> > No we don't strip js out of XML by intent (yet). Have you try to use
> HTML that itself contain a script tag, and an svg  tag with an ID so that
> you can refer to it ?
> >
> > Well, something is stripping it out, between the call to
> IPython.display.SVG() and what Firefox tells me it sees.  Since I need this
> to work for the tutorial, I am just going to have to assume that this is a
> bug somewhere and go for the embedded HTML approach that you suggest, since
> most of those at the tutorial would have this bug.
>
> Could it be linked to
> https://github.com/ipython/ipython/issues/1866 ?
>
> Can you share an ipynb so that I can take a look ?
> --
> Matthias
>
>
> >
> > Cheers!
> > Ben Root
> > _______________________________________________
> > IPython-dev mailing list
> > IPython-dev@scipy.org
> > http://mail.scipy.org/mailman/listinfo/ipython-dev
>
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL:
> http://mail.scipy.org/pipermail/ipython-dev/attachments/20130603/3c8ffd44/attachment-0001.html
>
> ------------------------------
>
> _______________________________________________
> IPython-dev mailing list
> IPython-dev@scipy.org
> http://mail.scipy.org/mailman/listinfo/ipython-dev
>
>
> End of IPython-dev Digest, Vol 113, Issue 5
> *******************************************
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/ipython-dev/attachments/20130604/e375fe0d/attachment-0001.html 


More information about the IPython-dev mailing list