Loading ...
Sorry, an error occurred while loading the content.

Re: [ydn-javascript] Autocomplete - Custom Format with Button- Help with adding button event handler

Expand Messages
  • Eric Miraglia
    Pradeep, The best way to handle the button click is to listen for it using a single event handler at the container level; this uses a technique called event
    Message 1 of 2 , Apr 29, 2009
    • 0 Attachment
      Pradeep,

      The best way to handle the button click is to listen for it using a single event handler at the container level; this uses a technique called event delegation that relies on the "click" event bubbling up the dom.  We have an event delegation tutorial here:


      This should help you get started.

      Regards,
      Eric


      On Apr 27, 2009, at 8:29 PM, Pradeep Kumar wrote:

      Hi,

      I have used the formatResult to modify the container and generate each list element with 2 items.

      The formatResult function is:

      myAC.formatResult = function(oResultDat a, sQuery, sResultMatch) {

      return "<div class='result' id='resultDivId' >"
      + oResultData. Title
      + "<span id='pushbutton1' class='yui-button yui-push-button' >"
      + "<span class='first- child'>"
      + "<button id='pushbutton1- button" type='button' >More Info</button> "
      +"</span></span> "
      + "</div>";
      }

      With this we do see that whenever autocomplete suggests a list of items, each row has a button. Now, I need to add a functionality such that on button click I do something with the data (oResultData) .

      The problem with this is - I can't add the onClick code in the code above since all parameters I pass are stringized.

      Also, AutoComplete doesn't support the Event - ButtonClickEvent.

      Could someone help me with this - as to where and how I need to subscribe this event?


    Your message has been successfully submitted and would be delivered to recipients shortly.