The real content is not just a string like "This is my awesome string" but
has a few variables and associated conditions. This is actually a little
exception because it is not usually something I assign to a javascript
variable.

I use elements when the result should be render initially in the view and
later in response of an ajax call that update the elements so I can use
query to update the object.

ex:
index.ctp:

...
<div id="myAwesomeDiv">
element('DoneShare/completed', array('completed_time' => $completed_time))
</div>
...

ajax_update.ctp

$ret = array('status' => 'ok', 'html' => element('DoneShare/completed',
array('completed_time' => $completed_time)) );
echo json_encode($ret);

And with jquery I do something like $("#myAwesomeDiv") .html(data.html); in
the success callback of the ajax call.


On Wed, Feb 8, 2012 at 1:13 PM, AD7six <[email protected]> wrote:

>
>
> On Feb 8, 8:54 pm, Chris Cinelli <[email protected]>
> wrote:
> > BTW, the a patch is using: preg_replace ('/<!--.*-->\s/',
> > '', $this->element(...)); but it seems a little an overkill
> >
> > On Wed, Feb 8, 2012 at 11:44 AM, Chris Cinelli <
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > [email protected]> wrote:
> > > Just to clarify this is what Ia  trying to do:
> >
> > > In the view I have
> > > <script>
> > >  var completedText           =   '<?=
> > > $this->element('DoneShare/completed', array('completed_time' => $
> > > completed_time)) ?>';
> > > </script>
> >
> > > This work well when the DebugKit is not active  producing this output:
> > > <script>
> > >  var completedText           =   'This is my awesome string!';
> > > </script>
> >
> > > But when the DebugKit is active, it render like:
> >
> > > var completedText           = '<!-- Starting to render -
> DoneShare/completed -->
> > >     This is my awesome string
> > > <!-- Finished - DoneShare/completed -->
> > > ';
> >
> > > that produce a javascript error.
> >
> > > Since I would like to keep the debug kit on in development, it would be
> > > nice if I can turn off the rendering of the debugging comments just for
> > > that specific element.
> >
> > > Any solution for that?
> >
> > > Best,
> > >    Chris
> >
> > > On Tue, Feb 7, 2012 at 2:45 PM, Chris Cinelli <
> > > [email protected]> wrote:
> >
> > >> I would like to turn off in a specific instruction $this->element(...)
> > >> the behavior that the DebugKit has to add prepending line with "<!--
> > >> Rendiring xxx -->" etc.
> > >> The result of the element rendering goes in a string that should not
> have
> > >> those HTML comments.
> > >> I would like to be able to keep the debug kit on except in that
> specific
> > >> instance.
> >
> > >> Is there a way to achieve that ?
> >
> > >> Best,
> > >>     Chris
> >
> > >> --
> > >> --Everything should be made as simple as possible, but not simpler
> > >> (Albert Einstein)
> >
> > > --
> > > --Everything should be made as simple as possible, but not simpler
> (Albert
> > > Einstein)
> >
> > --
>
> "Everything should be made as simple as possible, but not simpler
> (Albert
> > Einstein"
>
> How about not using an element for returning data (elements are not
> designed to do that) and instead using a helper function?
>
> AD
>
> --
> Our newest site for the community: CakePHP Video Tutorials
> http://tv.cakephp.org
> Check out the new CakePHP Questions site http://ask.cakephp.org and help
> others with their CakePHP related questions.
>
>
> To unsubscribe from this group, send email to
> [email protected] For more options, visit this group
> at http://groups.google.com/group/cake-php
>



-- 
--Everything should be made as simple as possible, but not simpler (Albert
Einstein)

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
[email protected] For more options, visit this group at 
http://groups.google.com/group/cake-php

Reply via email to