Thanks francky.. This community rocks.. :)...

On Sat, Jun 14, 2008 at 9:09 PM, francky06l <[EMAIL PROTECTED]> wrote:

>
> You could declare, after the list of comment, an empty "comment" for
> future insertion :
>
> <div id="last_comment"></div>
>
> Then in your view, make a javascript block :
>
> $last_post = '<p>'.$comment.'</p>';   // format the display of your
> comment
> $last_post .= '<div id="last_comment"></div>';   // add a new place
> holder for last_comment
> $last_post  = str_replace(array('%','/','<',"\\","\r","\n",'"'),
>
> array('%25','\/','%3C','\\','','\r\n','\"'),
>                                     $last_post);   // escape the inserted
> html
> $last_post =  'unescape("' . $last_post . '")';   // add unescape in
> javascript
>
> $js = "elem = $('last_comment'); Element.replace(elem,
> '{$last_post}');";    // replace the last_comment by the html comment
> + a new div
> echo $javascript->codeBlock($js);   // echo the javascript
>
> Basically in the above, you replace the last_comment div, by the post
> (html) and you add again a last_comment div (for next post) ..etc ..
> The code here, is to give you an idea, you have "escape" the Html,
> that's why I do the str_replace and the unescape after..
> I just wrote this without testing the above code, I hope this helps
>
>
>
> On Jun 14, 2:58 pm, Novice <[EMAIL PROTECTED]> wrote:
> > Hello fracnky,
> >
> > I dont actually yield out the whole comment pane from the view of add
> > action after the user has published a comment. I yield out only the
> > single comment the user has posted or error in case there is an error.
> > Thats why i am facing the trouble.. I hope i were clear.
> >
> > thanks.
> >
> > On Jun 14, 5:18 pm, francky06l <[EMAIL PROTECTED]> wrote:
> >
> > > you can update several divs using a view such as :
> >
> > > echo $ajax->div('div1');
> > > ..
> > > .. html code or javascript
> > > echo $ajax->divEnd('div1');
> >
> > > echo $ajax->div{'div2')
> > > .. html
> > > echo $ajax->divEnd('div2');
> >
> > > The div1 and div2 will be updated if they are into the 'update'
> > > array..
> > > div1, could be the error div, in case of errors the view will contain
> > > $ajax->div('div1'),
> > > if error you set the content of div1, otherwise you do not "mention"
> > > div1 ..something like
> >
> > > if(isset($error))
> > > {
> > >    echo $ajax->div('div1');
> > >    // show you error in the div
> > >    echo $ajax->dviEnd('div1');
> >
> > > }
> >
> > > hth
> >
> > > On Jun 14, 12:00 pm, "Novice Programmer" <[EMAIL PROTECTED]>
> > > wrote:
> >
> > > > Hello Alessio,
> >
> > > > If i understood it correctly, then you are having a comments box
> where the
> > > > user posts comment, after he posted the comment you want to update
> comments
> > > > area without updating the page, right? if thats the case, then i am
> also
> > > > stuck with a same problem. My question is that how do you deal with
> error
> > > > case? Lets say that the validation failed while adding the comment,
> then you
> > > > cant update the comments area, you have to show error some where
> else(say on
> > > > the top of comments box). How do you handle this situation?
> >
> > > > Thanks.
> >
> > > > On Thu, Jun 12, 2008 at 10:56 PM, Alessio <[EMAIL PROTECTED]>
> wrote:
> >
> > > > > Because I love this community and I want to help nexts with this
> > > > > problem...
> > > > > Don't try to update two fields...
> >
> > > > > A good solution is use javascript code function, using the complete
> > > > > trigger;
> >
> > > > > <?php echo $ajax->form('/comments/add', 'post', array( 'url' => '/
> > > > > comments/add', 'update' => 'feed','complete'=>"update2divs()" /
> > > > > *'indicator' => 'commentSaved'*/));?>
> >
> > > > > On complete I call my function called update2divs
> >
> > > > > In my file of javascript i have this function:
> >
> > > > > function update2divs() {
> >
> > > > > new Ajax.Updater('PostsComments', root + '/tests/hello',
> > > > > { method: 'post',
> > > > >  insertion: Insertion.Bottom });
> >
> > > > > }
> >
> > > > > Interesting solution...
> > > > > Because I can call my function and append the html in bottom or
> top...
> >
> > > > > The root is a general var, because, i have my root site in
> > > > > subfolder...and when you upload in your site...
> > > > > THat all...
> > > > > So I can update my div, and give feedback to user of some
> error...and
> > > > > if completed succefully the request...
> > > > > I append the data to the div...without refreshing all the page..
> but
> > > > > simply append the data...
> >
> > > > > I cannot immagine a better solution, considering not spending
> > > > > resources in the server...
> >
> > > > > So if you want to complete the cake, it would be interesting to put
> > > > > focus on the div...but i have read that exists some problem with
> > > > > different browser....
> >
> > > > > Good job...
> >
> > > > > On 12 Giu, 17:42, Alessio <[EMAIL PROTECTED]> wrote:
> > > > > > <?php echo $ajax->form('/comments/add', 'post', array( 'url' =>
> '/
> > > > > > comments/add', 'update' => 'feed', 'indicator' =>
> 'commentSaved'));?>
> >
> > > > > > I tried many option to update more div...
> > > > > > for example putting 'update' =>array.....
> > > > > > But is it possible?
> >
> > > > > > How can I to say to cake to create two update div?
> > > > > > In one, I need show the comments...
> > > > > > And in the other div I need to show the message "saved" or
> "error";
> >
> > > > > > I can use also javascript:
> >
> > > > > > function update2divs(parameters) {
> > > > > >     ajaxupdate('div1','url');
> > > > > >     ajaxupdate('div2','url2');
> >
> > > > > > }
> >
> > > > > > But How can I call this function, using $ajax->form?
> >
> > > > > > Another question, how can I move the focus on a div...I need to
> show
> > > > > > the comment when the user has finished posting the comment.
> >
> > > > > > Very thanks.
> >
> > > > --
> > > > Thanks & Regards,
> > > > Novice.
> >
>


-- 
Thanks & Regards,
Novice.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to