you may be able to get the clicked element with "this"

Example.

$('clones').observe('click',function(evt){
      var elm = this;
...................... var e=this.id; 
----- Original Message ----- 
  From: Yan Kovyakh 
  To: prototype-scriptaculous@googlegroups.com 
  Sent: Tuesday, July 21, 2009 2:32 PM
  Subject: [Proto-Scripty] Delete php


  Look like it can't find the element or the id of the element, because all 
that gets send is "clone" and nothing more.

   

   

  > either its not getting the element or var id=...split()..... is resetiing

  > something...

  > 

  > Try

  > 

  > var theid = elm.id.split('_').last();parameters :{clone:id}...Or if you 

  >cant

  > do it in javascript send the whole id of the element and split it in

  > php<?php // remove_clone.php$id=end(explode("_",$_POST['clone'])); ?>

  > 

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

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

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

  > Sent: Tuesday, July 21, 2009 12:38 PM

  > Subject: [Proto-Scripty] Delete php

  > 

  > > I'm getting true in a test but NULL as an post ID. Every element has an

  > > Id:

  > 

  > > <li id="Item_5">5<span class="remove">(x)</span></li>

  > 

  > > I'm getting frustrated as much as you do Alex, the last pledge for help

  > > would be to send in the whole script.

  > 

  > >http://pastie.org/553229

  > 

  > >> I suggest you give up lol because it really doesnt get any simpler than

  > 

  > >>  what i offered.

  > 

  > >> If however you do not wish to give up i will give you the answer.

  > 

  > >> var e=evt.element().id;

  > 

  > >> ....................................

  > 

  > >> Then use the script given to you by me to get the actual ID from "e"

  > 

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

  > 

  > >>   From: Yan Kovyakh

  > 

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

  > 

  > >>   Sent: Tuesday, July 21, 2009 11:47 AM

  > 

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

  > 

  > >>   Don't really understand what should I do with that line?

  > 

  > >>   > var elm=evt.element().id; //is the id of the element no ?

  > 

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

  > 

  > >>   >   From: Yan Kovyakh

  > 

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

  > 

  > >>   >   Sent: Tuesday, July 21, 2009 11:27 AM

  > 

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

  > 

  > >>   >   Well yes, this does gives me a true, and in post of the

  > 

  > >>  remove_clone.php

  > 

  > >>   > I see "clone 1234".

  > 

  > >>   >  But that's because you specified

  > 

  > >>   >   var e='blah_1234';

  > 

  > >>   >   But how am I going to connect my clone:id parameter?

  > 

  > >>   >   > Here is one way to do it (though probably not the best)

  > 

  > >> - but it works

  > 

  > >>   >   >  var e='blah_1234';

  > 

  > >>   >   >  var i=e.split('_');

  > 

  > >>   >   >  var l=i.length-1;

  > 

  > >>   >   > var id=(l>=1) ? i[l] : 'NULL' ;

  > 

  > >>   >   > var test=(id.length>=1) ? true : false ;

  > 

  > >>   >   > alert(test); // true means its set and has a string

  > 

  > >>  length greater

  > 

  > >>   >  than 1,

  > 

  > >>   >   > false means there is nothing after "_"

  > 

  > >>   >   > then you can test it with

  > 

  > >>   >   > if(test!==true) {

  > 

  > >>   >   > alert('No ID Found');

  > 

  > >>   >   > return

  > 

  > >>   >   > }

  > 

  > >>   >   > parameters : { clone: id }

  > 

  > >>   >   > HTH

  > 

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

  > 

  > >>   >   >   From: Yan Kovyakh

  > 

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

  > 

  > >>   >   >   Sent: Tuesday, July 21, 2009 10:00 AM

  > 

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

  > 

  > >>   >   >   I don't really want to change the whole scripts

  > 

  > >> , and the problem i

  > 

  > >>   >  that

  > 

  > >>   >   >I can't get the ID out, not the script.

  > 

  > >>   >   >   Is there any way to extract an ID instead of doing:

  > 

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

  > 

  > >>   >   >   Because everything up to that point is working

  > 

  > >> , I'm confused.

  > 

  > >>   >   >   > Ya, I'm getting an empty box, so something

  > 

  > >>  is wrong.

  > 

  > >>   >   >   > > Dude, firstly please stop topping the message

  > 

  > >>  and removing the

  > 

  > >>   >  code

  > 

  > >>   >   > and

  > 

  > >>   >   >   > >replies from your replies.

  > 

  > >>   >   >   > > secondly: try the below script and see

  > 

  > >>  what gets alerted (it

  > 

  > >>   >  should

  > 

  > >>   >   >be

  > 

  > >>   >   >   > >your numeric ID, if not then you have

  > 

  > >>  something wrong somewhere

  > 

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

  > 

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

  > 

  > >>   >   >   > >       if (elm.hasClassName('remove')){

  > 

  > >>   >   >   > >         evt.stop();

  > 

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

  > 

  > >>   >   >   > > alert(id);

  > 

  > >>   >   >   > > return;

  > 

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

  > 

  > >>   >   >   > >           parameters:{clone:id},

  > 

  > >>   >   >   > >           onSuccess:function(transport){

  > 

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

  > 

  > >>   >   >   > >             pollSortable.defer();

  > 

  > >>   >   >   > >           }

  > 

  > >>   >   >   > >         });

  > 

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

  > 

  > >>   >   >   > >   From: Yan Kovyakh

  > 

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

  > 

  > >>   >   >   > >   Sent: Monday, July 20, 2009 7:35 PM

  > 

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

  > 

  > >>   >   >   > >   They actualy have Item_numericalID

  > 

  > >>   >   >   > >   Is this the problem?


  

--~--~---------~--~----~------------~-------~--~----~
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