Alert works up to the last 2 lines, up to the elm.up('li').remove();

 

> Put an alert in there, or a console.log, and see if your Ajax.Request  

> is even returning success. If it doesn't, you will never see anything  

> happen to that list item.

> 

> Walter

> 

> On Jul 21, 2009, at 1:47 PM, Yan Kovyakh wrote:

> 

> > Great, now it finds the correct ID, and sends a post of "clone ID"  

> > but the rest of the code seems not working:

> 

> > new Ajax.Request('remove_clone.php',{

> >           parameters:{clone:the_id},

> >           onSuccess:function(transport){

> >             elm.up('li').remove();

> >             pollSortable.defer();

> >          }

> >      });

> >    });

> > });

> 

> > The last 2 lines of the code doesn't work, it's not removing the li  

> > anymore.

> 

> > > $$('#clones li').invoke('observe','click',function(event) {

> > >           var elm=this;

> > >       if (elm.hasClassName('remove')){ // this was unclosed

> 

> > >     Event.stop(event);

> > >     } // now closed properly

> > >       var the_id = elm.id.split('_').last();

> > >        alert(the_id);  // remove this to make it work

> > >          return; // remove this to make it work

> > >         new Ajax.Request('remove_clone.php',{

> > >           parameters:{clone:the_id},

> > >           onSuccess:function(transport){

> > >             elm.up('li').remove();

> > >             pollSortable.defer();

> > >           }

> > >         });

> > >  });

> 

> > > That works because i just tested it, it alerts 1234 for the  

> > follwing html

> > > and 4567 for the second list element.

> 

> > > See the comments in the code to make it work for you.

> 

> > > <ul id="clones">

> > >     <li id="foo_1234">ID = foo_1234</li>

> > >      <li id="foo_4567">ID = foo_4567 </li>

> > >   </ul>

> 

> > > Alex Mcauleyhttp://www.thevacancymarket.com

> 

> > > ----- Original Message -----

> > > From: "Yan Kovyakh" <maybe...@gmail.com>

> > > To: <prototype-scriptaculous@googlegroups.com>

> > > Sent: Tuesday, July 21, 2009 5:17 PM

> > > Subject: [Proto-Scripty] Delete php

> 

> > > > Says nothing, it's unclick-able now.

> 

> > > >>and firebug says ?

> 

> > > >>you have an undefined error in there for a start with evt.stop();

> 

> > > >>Alex Mcauley

> > > >>http://www.thevacancymarket.com

> > > >>----- Original Message -----

> > > >>From: "Yan Kovyakh" <maybe...@gmail.com>

> > > >>To: <prototype-scriptaculous@googlegroups.com>

> > > >>Sent: Tuesday, July 21, 2009 5:04 PM

> > > >>Subject: [Proto-Scripty] Delete php

> 

> > > >> Both of the solutions causes script not to work at all, just to  

> > make

> > > >> sure  I'm connecting all right.

> > > >>http://jsbin.com/igixe/edit

> 

> > > >>> Okay.

> 

> > > >>> Your script is listening to the <ul> list with ID of "clones"  

> > so you

> > > >>> will

> > > >>> never get an element id that is not "clones" because it is

> > > >>listening on  the

> > > >>> <ul>

> 

> > > >>> event.element() should track it but its not working...

> 

> > > >>> solution 1. use this insetad

> > > >>> $('clones').observe('click',function(event){

> > > >>> var elm=Event.element(event);Rest of your code

> 

> > > >>> Solution 2.

> 

> > > >>> Listen to each <li> inside the <ul> for the click like the  

> > following

> 

> > > >>> $$('#clones li').invoke('observe','click',function(event) {

> 

> > > >>> var elm=this; // this will now be the element (this.id will be  

> > its ID)

> 

> > > >>> rest of your code.

> 

> > > >>> });

> 

> > > >>> HTH

> > > >>> Alex Mcauleyhttp://www.thevacancymarket.com

> 

> > > >>> ----- Original Message -----

> > > >>> From: "Yan Kovyakh" <maybe...@gmail.com>

> > > >>> To: <prototype-scriptaculous@googlegroups.com>

> > > >>> Sent: Tuesday, July 21, 2009 4:26 PM

> > > >>> Subject: [Proto-Scripty] Delete php

> 

> > > >>> > Maybe there's something completely other that causes this  

> > problem

> > > >>> >, if   someone look at it  http://pastie.org/553229

> 

> > > >>> >> Already been tried !!!

> 

> > > >>> >> ----- Original Message -----

> > > >>> >> From: "Walter Lee Davis" <wa...@wdstudio.com>

> > > >>> >> To: <prototype-scriptaculous@googlegroups.com>

> > > >>> >> Sent: Tuesday, July 21, 2009 4:14 PM

> > > >>> >> Subject: [Proto-Scripty] Re: Delete php

> 

> > > >>> >> > Try this:

> 

> > > >>> >> > $('clones').observe('click',function(evt){

> > > >>> >> > var elm = evt.element();

> > > >>> >> > if(elm.id){

> > > >>> >> > //your code goes here

> > > >>> >> > }

> > > >>> >> > });

> 

> > > >>> >> > Walter


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to