1 Reply Latest reply on Aug 23, 2009 9:05 PM by babo_ya

    Passing values with currentTarget

    rcanulla Level 1

      Hi there,


      I have a list of dynamically created objects (VO) (title, item, id). I want dynamically create delete buttons, and pass the id of the currentItem that the user clicks.


      How I create the items

      <mx:Repeater id="repeat" dataProvider="{taskData}">
                          <mx:Label text="{VOAuthor(repeat.currentItem).contactName} @ {VOAuthor(repeat.currentItem).company}" fontWeight="bold" fontSize="14" color="#000000"/>
                               <mx:Label htmlText="{VOAuthor(repeat.currentItem).quoteDate}" color="#000000"/>
                               <mx:Label htmlText="{VOAuthor(repeat.currentItem).phone}" color="#000000"/>
                               <mx:Label htmlText="{VOAuthor(repeat.currentItem).email}" color="#000000"/>
                          <mx:Text htmlText="{VOAuthor(repeat.currentItem).comments}" width="90%" color="#000000"   text="test&#xd;"/>
      where i need help---->               <mx:LinkButton label="Delete" click="{onDeleteItem(event, VOAuthor(repeat.currentItem).id.toString())}"/>
                               <mx:LinkButton label="Reply to Quote" />
                          <mx:HRule width="95%" strokeWidth="1"/>


      here is the clickHandler

                  private function onDeleteItem(e:Event, id:String):void {
                       trace("### click ###");
                       //author = new VOAuthor();
                       //author = item;

        • 1. Re: Passing values with currentTarget
          babo_ya Level 3

          if the "id" is unique.. then.. you can do something like this..


          private function onDeleteItem(e:Event):void


               var label:Label = Label(e.currentTarget);

               var id:String = label.text;


               var i:int;

               var len:int = taskData;


               for(i = 0; i < len; i++)


                    var item:VOAuthor = taskData.getItemAt(i) as VOAuthor;


                    if(item.id == id)






          if the "id" is NOT unique... then you could create "guid" inside of the VOAuthor class and use that instead of "id"


          Hope this helps,