Have a look inside the jqGrid plugin (http://trirand.com/blog is where
you can find it).  Tony has done an absolutely fabulous job on his
grid plugin and his code is a wealth of information about how to build
components with jQuery.  One of the things you'll find in there is
dynamic script loading.

On Jan 9, 5:32 pm, "Josh Nathanson" <joshnathan...@gmail.com> wrote:
> I think that would work - I just tried this in Firebug on a page with
> jQuery:
>
> $('head').append("<script>alert('hello');</script>");
>
> Sure enough, it popped up an alert dialog.
>
> -- Josh
>
> -----Original Message-----
> From: jquery-en@googlegroups.com [mailto:jquery...@googlegroups.com] On
>
> Behalf Of yellow1912
> Sent: Friday, January 09, 2009 2:16 PM
> To: jQuery (English)
> Subject: [jQuery] Re: How to dynamically load/add inline javascript?
>
> I see. Thanks Josh. What if I dynamically insert the code into the
> head area, would that has the same effect?
>
> Regards
>
> Raine
>
> On Jan 9, 4:05 pm, "Josh Nathanson" <joshnathan...@gmail.com> wrote:
> > I think you have to strip the <script> tags off before you run eval().  I
> > just tried a little test using firebug:
>
> > Eval("<script>alert('hello');</script>");  FAIL
>
> > Eval("alert('hello')"); SUCCEED
>
> > -- Josh
>
> > -----Original Message-----
> > From: jquery-en@googlegroups.com [mailto:jquery...@googlegroups.com] On
>
> > Behalf Of yellow1912
> > Sent: Friday, January 09, 2009 1:54 PM
> > To: jQuery (English)
> > Subject: [jQuery] Re: How to dynamically load/add inline javascript?
>
> > I actually did, I put a very simple line
> > alert("testing");
>
> > No error, no effect, weird.
>
> > Regards
>
> > Raine
>
> > On Jan 9, 3:35 pm, MorningZ <morni...@gmail.com> wrote:
> > > "I wonder if eval will work correctly in this case? "
>
> > > Did you simply just try it?
>
> > > On Jan 9, 4:01 pm, yellow1912 <yellow1...@gmail.com> wrote:
>
> > > > Thanks Mike,
>
> > > > These inline script always come with
>
> > > > <script type="text/javascript"><!--
> > > > // code here
> > > > //--></script>
>
> > > > When I use firebug to check the json data returned, it looks like
> > > > this:
> > > > (I just post part of the code here)
> > > > --------------------------------
> > > > "jscript_inline":"<script language=\"javascript\" type=\"text\/
> > > > javascript
>
> > > > \"><!--\r\nalert('balh');\r\nvar selected;\r\nvar submitter = null;\r
> > > > \nfunction popupWindow(url) {\r
>
> > > > \n  window.open
>
> (url,'popupWindow','toolbar=no,location=no,directories=no,status=no,menubar=
> > no,scrollbars
>
> =yes,resizable=yes,copyhistory=no,width=450,height=320,screenX=150,screenY=1
> > 50,top=150,left=150')
> > > > \r\n
>
> > > > }\r\nfunction couponpopupWindow(url) {\r\n  window.open
>
> > > > (url,'couponpopupWindow','toolbar=no,location
> > > > --------------------------------
>
> > > > I wonder if eval will work correctly in this case?
>
> > > > Regards
>
> > > > Raine
>
> > > > On Jan 9, 2:50 pm, "Michael Geary" <m...@mg.to> wrote:
>
> > > > > You can execute JavaScript code with the eval function, e.g.
>
> > > > >     eval( result.jscript );
>
> > > > > -Mike
>
> > > > > > From: yellow1912
>
> > > > > > After I submit my form via ajax, I sometimes get back content
> (json
> > > > > > format) with some inline jscript in one of the fields (i.e:
> > > > > > result.jscript)
>
> > > > > > I've been trying to do something like this:
> > > > > > $('#output').append(result.jscript);
>
> > > > > > It doesn't seem to work, however.
>
> > > > > > (In my case, I can't avoid these inline jscript, so I can't
> > > > > > really put them in external js files to load)
>
> > > > > > I really hope someone can shed some light here
>
> > > > > > Regards
>
> > > > > > Raine

Reply via email to