Yes, That's because the 2 first return we get from the server, the query is not finish, therefore we don't have the new result. Using only %html wihtout string interpolation might not have this behavior though
On Thu, Nov 19, 2015 at 7:01 PM, Partridge, Lucas (GE Aviation) < lucas.partri...@ge.com> wrote: > Typo: > > “…and run the paragraph you’ll see ‘Hello Bob!’ appear in the paragraph 3 > times.” > > should be: > > “…and run the paragraph you’ll see ‘Hello Bob!’ appear in the Javascript > console 3 times.” > > > > *From:* Partridge, Lucas (GE Aviation) > *Sent:* 19 November 2015 09:52 > *To:* users@zeppelin.incubator.apache.org > *Subject:* RE: %html directive errors: 'invalid string interpolation' and > 'unclosed character literal' > > > > Hi Corneau, > > > > Thanks for the explanation. It definitely seems to be executed 3 times, in > zeppelin-0.5.0-incubating at least. It just means the user has to be > careful to make sure their HTML code executes only once, or at least that > it doesn’t matter if it does executes more than once. > > > > Another interesting thing is that if you change the code and re-run the > paragraph - the first 2 executions still use the previous version of the > code; only the 3rd execution uses the new code. So when you’re watching > the output in the Javascript console you just have to make sure you only > look at the output for the 3rd execution! For example, if you paste this > into a paragraph: > > > > print(s"""%html <div id="myDiv2" style="height:1px"></div> > > <script> > > jQuery('#myDiv2').ready(function() { > > console.log('Hello Bob!'); > > }); > > </script> > > """) > > > > …and run the paragraph you’ll see ‘Hello Bob!’ appear in the paragraph 3 > times. If you then change Bob to Fred and run the paragraph again, you’ll > see ‘Hello Bob!’ twice, followed by ‘Hello Fred!’. (And if you run the > paragraph again, without changing any code this time, you’ll see ‘Hello > Fred!’ three times.) > > > > I’m not sure if this is a bug but I thought you and other users ought to > be aware of this in case they’re struggling to understand the output from > their code… > > Lucas. > > > > *From:* Corneau Damien [mailto:cornead...@gmail.com <cornead...@gmail.com>] > > *Sent:* 19 November 2015 01:30 > *To:* users@zeppelin.incubator.apache.org > *Subject:* Re: %html directive errors: 'invalid string interpolation' and > 'unclosed character literal' > > > > Hi Lucas, > > The code might indeed be rendered multiple times since we receive the note > back for every step of the query, Like query start, query finishes etc... > > Although I thought I reduced it to 2 calls instead of 3 before. > > It's something that could probably be improved in Zeppelin by sending back > more specific response messages. > > For example: > * Sending back only the running paragraph instead of the full note > > * Sending back only the paragraph new status instead of the full note > > etc... > > > > > > On Wed, Nov 18, 2015 at 6:37 PM, Partridge, Lucas (GE Aviation) < > lucas.partri...@ge.com> wrote: > > Hi moon, > > > > Thanks very much for that! Yes, replacing $ with jQuery worked (regardless > of whether I used single or double quotes around #myDiv). I’ll be careful > with $ signs in %html directives with string interpolation thenJ. > > > > Note that the alert box pops up 3 times in all. Did you get that when you > ran the code? This relates to my previous postscript about the code being > executed 3 times in a paragraph. Is this expected behaviour?! > > > > Thanks, Lucas. > > > > > > *From:* moon soo Lee [mailto:m...@apache.org] > *Sent:* 18 November 2015 01:04 > *To:* users@zeppelin.incubator.apache.org > *Subject:* Re: %html directive errors: 'invalid string interpolation' and > 'unclosed character literal' > > > > Hi Lucas, > > > > Could you try > > > > jQuery("#myDiv") > > > > instead of > > > > $('#myDiv') > > > > ? It might help. > > > > Thanks, > > moon > > > > > > On Wed, Nov 18, 2015 at 1:30 AM Partridge, Lucas (GE Aviation) < > lucas.partri...@ge.com> wrote: > > Hi, > > > > I want to use string interpolation in a notebook paragraph so I can pass > variables from Scala into an %html directive for inline visualization. > (Indeed there’s an example of this at > https://www.zeppelinhub.com/viewer/notebooks/aHR0cHM6Ly9yYXcuZ2l0aHVidXNlcmNvbnRlbnQuY29tL0xlZW1vb25zb28vemVwcGVsaW4tZXhhbXBsZXMvbWFzdGVyLzJCMlhLRkNETS9ub3RlLmpzb24 > <https://urldefense.proofpoint.com/v2/url?u=https-3A__www.zeppelinhub.com_viewer_notebooks_aHR0cHM6Ly9yYXcuZ2l0aHVidXNlcmNvbnRlbnQuY29tL0xlZW1vb25zb28vemVwcGVsaW4tZXhhbXBsZXMvbWFzdGVyLzJCMlhLRkNETS9ub3RlLmpzb24&d=CwMFaQ&c=IV_clAzoPDE253xZdHuilRgztyh_RiV3wUrLrDQYWSI&r=c1CCNND4PG-Q_V2AJWDWrugZAXQ8Y3EE_f_mAHcpXcs&m=Ae4dMdeREmT6sBWn3LGYs8SWCPEciyDs49lZV14H1M0&s=SyunP56W9DpMp9aYSQvtvj3XvXdmzxdJWH9xuZBVQhk&e=> > ) > > > > However I’m getting weird errors when I try to use string interpolation. > Here’s a very simple example that illustrates the problem. Try pasting > this into a Zeppelin paragraph: > > > > print(s"""%html <div id="myDiv" style="height:400px"></div> > > <script> > > $('#myDiv').ready(function() { > > alert('My div is loaded!'); > > }); > > </script> > > """) > > > > When I run the paragraph I get these errors: > > > > <console>:1: error: invalid string interpolation: `$$', `$'ident or > `$'BlockExpr expected > > print(s"""%html <div id="myDiv" style="height:400px"></div> > > ^ > > > > <console>:3: error: unclosed character literal > $('#myDiv').ready(function() { > > > ^ > > > > Does anyone know how to fix these errors please? (I can get rid of the > second error by replacing the single quotes with double quotes in > $('#myDiv') but I’m not sure that’s the right thing to do!) > > > > Many thanks, > > Lucas. > > > > PS Incidentally I’ve noticed in the browser’s Javascript console that the > paragraph seems to get executed 3 times! Is this expected behaviour? I’m > using a standalone installation of the binary zeppelin-0.5.0-incubating. > > > > >