OK maybe I'm just being obtuse, but why would you put in newlines in
the string you're building and then str_replace them out ?
If you're going to pull them out anyway, why not just build the string
without them in the first place:
#
$js_ret = '$("task-'
js_ret .= $task['Task']['id'];
$js_ret .= '").remove();';
$js_ret .= 'Element.insert("completed_items", { top: "\u003Cdiv class=
\"completed\"'
##\n
$js_ret .= ' id=\"task-';
$js_ret .= $task['Task']['id'];
$js_ret .= '\"\u003E\u003Cinput '
## \n
$js_ret .= ' checked=\"checked\" class=\"checkbox\" onclick=\"new
Ajax.Request(\'/tasks/uncheck/'
$js_ret .= $task['Task']['id'];
$js_ret .='\'';
## \n
$js_ret .= ' ,{asynchronous:true, evalScripts:true})\" type=\"checkbox
\" ';
## \n
$js_ret .= ' /\u003E';
$js_ret .= $task['Task']['content'];
$js_ret .='\u003C/div\u003E"});';
$js_ret .= 'new Effect.Highlight("task-';
$js_ret .= $task['Task']['id'];
$js_ret .='",{});';
On Jan 6, 5:08 am, BarbarianGeek <[email protected]> wrote:
> I'm working on a tasklist in an application for my job. I'm trying to
> create something like the lists in <a
> href="http://www.backpackit.com">Backpack</a>.
>
> I have an AJAX request that fires off when a checkbox is clicked (and
> has evalScript set to true). Javascript is returned but never
> executes. When I paste the returned javascript into the console in
> Firebug, I get extra newline characters and an 'unterminated string
> literal'. When I remove the extra newlines, everything works.
>
> <a href="http://bin.cakephp.org/view/1058500436">Here is a paste bin
> with my view code.</a>
>
> Any ideas why I have the newlines cropping up? And is that really my
> problem or am I being confused by something else?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---