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

Re: [ydn-javascript] Split Button onclick question

Expand Messages
  • Todd Kloots
    Hey Bob - This is a bug. You can work around this issue by subscribing to the click event via the on method as opposed to the onclick attribute. For
    Message 1 of 2 , Aug 1, 2008
    • 0 Attachment
      Hey Bob -

      This is a bug. You can work around this issue by subscribing to the
      "click" event via the "on" method as opposed to the "onclick"
      attribute. For example:

      http://yuiblog.com/sandbox/yui/v252/examples/button/example12.html

      If you don't mind, please file a bug via SourceForge and I will try to
      address this issue in the next release of Button.

      Regards,
      Todd

      Bob Miller wrote:
      >
      > When I attach an onclick event to a split button or set onclick in the
      > configuration options the click handler gets fired both when I click
      > the button and when I open the menu on the button. Is there a way to
      > make the event not fire when I open the split menu?
      > You can get this behavior when the button is part of a form and you
      > attach a handler to the form submit event. (Like the YUI split button
      > example). Unfortunately my buttons are not in a form they can be the
      > submit for.
      > Here is the code I am using, I only have one event hooked up to the
      > menu so far but other events will be attached to different menu items
      > once I get this issue resolved:
      >
      > var splitButton = new YAHOO.widget.Button({
      > type: "split",
      > label: "<span>" + (textNode ? textNode.nodeValue : '') + "</span>",
      > menu: [
      > {
      > text: 'Open',
      > onclick: {
      > fn: this.code.titleClickListener,
      > obj: oTag.parentNode,
      > scope: this.code
      > }
      > },
      > {
      > text: 'Close'
      > },
      > {
      > text: 'Open All'
      > },
      > {
      > text: 'Print'
      > },
      > {
      > text: 'Bookmark'
      > }
      > ],
      > onclick: {
      > fn: this.code.titleButtonClickListener,
      > obj: oTag.parentNode,
      > scope: this.code
      > },
      > selectedMenuItem: 0,
      > title: 'Open'
      > });
      > splitButton.appendTo(oTag, oTag.firstChild);
      >
      >
    Your message has been successfully submitted and would be delivered to recipients shortly.