Here is a snippet of code that I had been using:

                buttons.add(buttonSets).click(function(event) {
                        var target = $(event.target);

                        if (target.closest('.ui-button').length) {
                                if (target.text() == "eat") {
                                        alert("eat");
                                } else if (target.text() == "sleep") {
                                        alert("sleep");
                                } else if (target.text() == "watch tv") {
                                        alert("watch tv");
                                }
                        }
                }

However, it doesn't work if you have a button with an icon and you
click on the icon since target.text() is "".  You have to use the more
familiar code that handles the click like this:

                $("#sloth").button(...)
                .click(function() {
                        alert("eat");
                })
                .next()
                .button(...)
                .click(function() {
                        alert("sleep");
                })
                .next()
                .button(...)
                .click(function() {
                        alert("watch tv");
                })
                .parent()
                .buttonset();

Note that I did a bunch of cut and pasting and modifying, so there may
be syntax errors.  But beyond syntax errors, any comments are welcome.

Chuck

-- 
You received this message because you are subscribed to the Google Groups 
"jQuery UI" group.
To post to this group, send email to jquery...@googlegroups.com.
To unsubscribe from this group, send email to 
jquery-ui+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/jquery-ui?hl=en.

Reply via email to