Well it looks like I got it all working. Now I just need to figure out
how to add some kind of effect to it. If anyone has any advice on
that, that would be perfect.

On Mar 9, 11:43 am, "Arak Tai'Roth" <nielsen.dus...@gmail.com> wrote:
> So I completely revamped the code in my ajax file to this:
>
> window.addEvent('domready', function()
> {
>         $('ajax_replace').addEvent('click', function(event)
>         {
>                 event.stop();
>
>                 var req = new Request(
>                 {
>                         method: 'get',
>                         url: $('ajax_replace').get('href'),
>                         data: { 'do' : '1' },
>                         onComplete: function(response)
>                         {
>                                 $('about_descriptioncontent').set('html', 
> response);
>                         }
>                 }).send();
>         });
>
> });
>
> It now kinda works. I had an onRequest portion in there and that was
> triggering, and the content was changing, it was incredibly messed up
> (ie. wasn't outputting what I was expecting it to). However this only
> works for the first of my links, the other ones don't do anything at
> all.
>
> On Mar 9, 11:25 am, "Arak Tai'Roth" <nielsen.dus...@gmail.com> wrote:
>
> > I don't want to do a simple GET request, I do want this as AJAX,
> > that's just the code I found. I am extremely new to MooTools, never
> > used it before this, in addition I am new to using AJAX period.
>
> > One thing I just realized and am slightly confused about. With the
> > code $('ajax_replace) I am under the understanding that I am
> > referencing the element id = ajax_replace. However I have multiples of
> > those on this page, 4 right now, likely more later once I have this
> > working. How does it know which one to add the event too (I want it
> > added to all of them) and how does it know which one to get the URL
> > from?
>
> > I am assuming it doesn't know, and might be the reason why things
> > aren't working.
>
> > On Mar 9, 11:06 am, mark_story <mark.st...@gmail.com> wrote:
>
> > > Well I would start with seeing if the Selector is working? does the
> > > click event even fire? I use mootools quite often, and there is
> > > nothing in cake that prevents you from doing so. Why aren't you just
> > > using Element.load() instead?  If you only want to do a simple GET
> > > request, I would just do
>
> > > window.addEvent('domready', function() {
> > >   $('ajax_replace').addEvent('click', function(event) {
> > >     event.stop();
> > >     $('about_descriptioncontent').load(this.get('href'));
> > >   }
>
> > > });
>
> > > Or you can keep your existing code, but you may want to prevent the
> > > default browser action anyways.  As you won't see the ajax result, as
> > > the default action will still happen.
>
> > > -Mark
>
> > > On Mar 9, 12:03 pm, "Arak Tai'Roth" <nielsen.dus...@gmail.com> wrote:
>
> > > > Also considering I am using multiple links I tried this as well:
>
> > > > url: $$('a.ajax_replace').get('href'),
>
> > > > and
>
> > > > $$('a.ajax_replace').addEvent('click', function()
>
> > > > and then changing the id's to classes. I was thinking this might work,
> > > > but alas, it did not either.
>
> > > > On Mar 9, 9:19 am, "Arak Tai'Roth" <nielsen.dus...@gmail.com> wrote:
>
> > > > > Yea, I'm sorry, I had fixed that problem a little while ago, that
> > > > > isn't the solution to the problem, it's still not working, and the
> > > > > page is still trying to load instead of working via AJAX.
>
> > > > > This is my code for the buttons I am making if that makes a
> > > > > difference.
>
> > > > > echo $html->link($html->image('/img/about/uploads/thumb.small.' .
> > > > > $links['About']['picture'], array('alt' => $links['About']['name'])),
> > > > > '/about/view/' . $links['About']['id'], array('id' => 'ajax_replace'),
> > > > > false, false)
>
> > > > > I'm not so sure the problem is with the javascript, I mean it totally
> > > > > could be, however I have found a few AJAX tutorials in MooTools, and
> > > > > the code I have is relatively copied. However I have found no
> > > > > tutorials anywhere regarding using MooTools AJAX with CakePHP, so
> > > > > what's really bothering me is the setting up the controller and how
> > > > > the associated view(s) should be set up.
>
> > > > > On Mar 9, 3:10 am, r4zv4n <razvanbra...@gmail.com> wrote:
>
> > > > > > Hi,
>
> > > > > > The fact that the page is loading instead of the Ajax request being
> > > > > > sent should signal that there's an error in your JS (if it were a 
> > > > > > Cake
> > > > > > err, you would have had weird responses).
>
> > > > > > Upon closer inspection, here is the problem:
>
> > > > > > $('ajax_replace').addEvent('click', function(
> > > > > >         {
> > > > > >                 req.send();
> > > > > >         });
>
> > > > > > ..should actually be:
>
> > > > > > $('ajax_replace').addEvent('click', function()
> > > > > >         {
> > > > > >                 req.send();
> > > > > >         });
>
> > > > > > (you simply missed a closing parenthesis)
>
> > > > > > Tip: use Firefox with FireBug  - you would have seen the error
> > > > > > sooner ;)
>
> > > > > > On Mar 9, 12:36 am, "Arak Tai'Roth" <nielsen.dus...@gmail.com> 
> > > > > > wrote:
>
> > > > > > > I tried that, and removed my autoRender and exit() lines and 
> > > > > > > added in
> > > > > > > $this->render(index); It didn't work.
>
> > > > > > > The page is still loading, which it shouldn't be with an AJAX 
> > > > > > > request
> > > > > > > as far as I know.
>
> > > > > > > In addition I added a $this->Session->setFlash('message'); inside 
> > > > > > > the
> > > > > > > isAjax() if statement and it doesn't pop up.
>
> > > > > > > I should also say that I have multiples of these links
> > > > > > > ('ajax_replace'), not just one, if that makes a difference.
>
> > > > > > > As well, I have two views right now, I have my index.ctp view 
> > > > > > > which is
> > > > > > > displaying the links and the first content that comes up (a 
> > > > > > > picture
> > > > > > > and some text), then I have my vew.ctp which currently is only 
> > > > > > > holding
> > > > > > > the content that I want to show where the current picture and 
> > > > > > > text is.
> > > > > > > So I'm not entirely sure if I even have this setup correctly.
>
> > > > > > > On Mar 8, 3:17 pm, "Websta*" <subscripti...@webprogression.co.nz>
> > > > > > > wrote:
>
> > > > > > > > Assuming your request is running - and i can see no reason why 
> > > > > > > > it
> > > > > > > > wouldnt as long as you have the correct html elements in use 
> > > > > > > > then i
> > > > > > > > suspect your problem lies here:
>
> > > > > > > > $this->autoRender = false;
> > > > > > > > exit();
>
> > > > > > > > By doing this your teling your controller not to render after 
> > > > > > > > the
> > > > > > > > action, and then your exiting so nothing at all gets output.
>
> > > > > > > > So either get rid of those lines altogether or if you want to 
> > > > > > > > forcibly
> > > > > > > > render a specific view replace it with $this->render(myView);
>
> > > > > > > > hth
>
> > > > > > > > Paul
>
> > > > > > > > On Mar 8, 6:09 pm, "Arak Tai'Roth" <nielsen.dus...@gmail.com> 
> > > > > > > > wrote:
>
> > > > > > > > > I am trying to update a div via ajax, however I am using 
> > > > > > > > > MooTools, and
> > > > > > > > > not the normal Prototype and Scriptaculous.
>
> > > > > > > > > Here is the code that I have in my controller:
> > > > > > > > > function view($id)
> > > > > > > > >                 {
> > > > > > > > >                         if ($this->RequestHandler->isAjax())
> > > > > > > > >                         {
> > > > > > > > >                                 $dbabout = 
> > > > > > > > > $this->About->find('first', array(
> > > > > > > > >                                         'conditions' => array(
> > > > > > > > >                                                 'About.id' => 
> > > > > > > > > $id
> > > > > > > > >                                         ),
> > > > > > > > >                                         'fields' => array(
> > > > > > > > >                                                 'About.id', 
> > > > > > > > > 'About.name', 'About.picture', 'About.description'
> > > > > > > > >                                         )
> > > > > > > > >                                 ));
> > > > > > > > >                                 $this->set('dbabout', 
> > > > > > > > > $dbabout);
>
> > > > > > > > >                                 Configure::write('debug', 0);
> > > > > > > > >                                 $this->autoRender = false;
>
> > > > > > > > >                                 exit();
> > > > > > > > >                         }
> > > > > > > > >                         else
> > > > > > > > >                         {
> > > > > > > > >                                 $this->redirect('/about/');
> > > > > > > > >                                 $this->exit();
> > > > > > > > >                         }
> > > > > > > > >                 }
>
> > > > > > > > > and then my ajax:
> > > > > > > > > window.addEvent('domready', function()
> > > > > > > > > {
> > > > > > > > >         var req = new Request.HTML(
> > > > > > > > >         {
> > > > > > > > >                 url: $('ajax_replace').get('href'),
>
> > > > > > > > >                 onSuccess: function(html){
> > > > > > > > >                         
> > > > > > > > > $('about_descriptioncontent').adopt(html);
> > > > > > > > >                 }
> > > > > > > > >         });
>
> > > > > > > > >         $('ajax_replace').addEvent('click', function(
> > > > > > > > >         {
> > > > > > > > >                 req.send();
> > > > > > > > >         });
>
> > > > > > > > > });
>
> > > > > > > > > The problem is nothing is happening, plus when I click one of 
> > > > > > > > > the
> > > > > > > > > links it looks like the page itself is re-loading, which 
> > > > > > > > > shouldn't be
> > > > > > > > > happening if it's Ajax. I have the view controller sending 
> > > > > > > > > data to
> > > > > > > > > view.ctp, which I was hoping would be adopted in the div I 
> > > > > > > > > want to
> > > > > > > > > update as per the ajax above.
>
> > > > > > > > > If anyone can help me out with this that would be awesome, 
> > > > > > > > > thanks in
> > > > > > > > > advance.
--~--~---------~--~----~------------~-------~--~----~
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 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to