It depends on what get_page(selection,text,form)  does

try one of the following:

  import gluon.contrib.simplejson as sj

  return "jQuery('#target').html(%s);" % sj.dumps(str(get_page
(selection,text,form)))
  return "jQuery('#target').html(%s);" % sj.dumps(repr(get_page
(selection,text,form)))
  return "jQuery('#target').html('%s');" % sj.dumps(str(get_page
(selection,text,form)))
  return "jQuery('#target').html('%s');" % sj.dumps(repr(get_page
(selection,text,form)))
  return 'jQuery("#target").html("%s");' % sj.dumps(str(get_page
(selection,text,form)))
  return 'jQuery("#target").html("%s");' % sj.dumps(repr(get_page
(selection,text,form)))



On Oct 11, 9:08 am, weheh <richard_gor...@verizon.net> wrote:
> I'm doing an ajax call that returns back a bunch of stuff including
> html and multiple javascripts. I want the html presented as is and the
> javascripts evaluated. All of it gets sent to a single target.
>
> The call looks like this:
>  DIV(...page-within-a-page with many subdivs and
> javascripts ...,_id='target')
>  DIV(
>    A(link_text,
>      _href='#',
>      _id=id,
>      _onclick="ajax('get_selection,['%s'],':eval');" % id
>      ),
>    ),
>
> The getselection controller looks like this:
>
> def get_selection():
>   selection = db(...).select(...)
>   text = ... open and read a file of text or html ...
>   form = FORM(...)
>   return "jQuery('#target').html(%s);" % get_page(selection,text,form)
>
> where get_page builds a complex page-within-a-page with javascript
> rollover buttons and a javascript-driven control.
>
> Problem is, everything is getting evaluated. So any single quotes in
> the text screw things up. How can this be done so that the text comes
> out as text and the javascript as an evaluated javascript?
>
> Originally, I tried just returning everything as html and stuffing it
> into the target div, but my javascripts didn't work any more, even
> though they were declared outside the target div. Can anyone explain
> why those javascripts wouldn't work after an ajax call and return?
>
> I'm a novice ajax user, so any insights into what is going on with the
> DOM during the ajax calling process would be helpful.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to