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 then☺.
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<mailto: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.