Skip to main content

Search and Top Navigation

#5554 closed feature (invalid)

Opened April 27, 2010 07:47AM UTC

Closed November 01, 2012 09:17AM UTC

Button: Provide an "activate" event/callback

Reported by: ddegasperi Owned by: ddegasperi
Priority: minor Milestone: 1.11.0
Component: ui.button Version: 1.8
Keywords: Cc:
Blocked by: Blocking:
Description

It would be nice if the button widget provides a method "activate", which executes the code bound to the click event and changes the classes in case of a buttonset (radios).

As it is now, i have to trigger the change event on triggered click.

Example HTML:

<div id="toolbarOpenLayers">
    <input type="radio" id="btnSelectFeature" name="toolbarOpenLayersItem" checked="checked" /><label for="btnSelectFeature">Button1</label>
    <input type="radio" id="btnRoutingStart" name="toolbarOpenLayersItem" /><label for="btnRoutingStart">Button2</label>
    <input type="radio" id="btnRoutingEnd" name="toolbarOpenLayersItem" /><label for="btnRoutingEnd">Button3</label>
    <input type="radio" id="btnRoutingEdit" name="toolbarOpenLayersItem" /><label for="btnRoutingEdit">Button4</label>
    <input type="radio" id="btnHelp" name="toolbarOpenLayersItem" /><label for="btnHelp">Button5</label>
</div>

Example JavaScript:

jQuery("#toolbarOpenLayers").buttonset();
jQuery('#btnSelectFeature').bind('click', function() { jQuery(this).attr('checked', true).trigger('change'); doSomethingElse(); } );
jQuery('#btnRoutingStart').bind('click', function() { jQuery(this).attr('checked', true).trigger('change'); doSomethingElse(); } );
jQuery('#btnRoutingEnd').bind('click', function() { jQuery(this).attr('checked', true).trigger('change'); doSomethingElse(); } );
jQuery('#btnRoutingEdit').bind('click', function() { jQuery(this).attr('checked', true).trigger('change'); doSomethingElse(); } );
jQuery('#btnHelp').bind('click', function() { doSomethingElse(); } );

jQuery('#btnRoutingStart').trigger('click');
Attachments (0)
Change History (10)

Changed February 27, 2012 01:41PM UTC by jzaefferer comment:1

We've discussed adding an event to Button, instead of triggering a fake/native click event on the original element, which we currently do. Not sure if that is covered somewhere, leaving this open for now.

Changed June 26, 2012 01:22AM UTC by scottgonzalez comment:2

type: enhancementfeature

Changed October 11, 2012 09:04PM UTC by scottgonzalez comment:3

milestone: TBD1.11.0

Changed October 15, 2012 03:29PM UTC by bchiasson comment:4

summary: button with method activateButton: Provide an "activate" event/callback

Changed October 15, 2012 09:09PM UTC by petersendidit comment:5

owner: → ddegasperi
status: newpending

Can you explain what you're currently doing and what problems you're facing? It's not clear exactly what you're asking for.

Changed October 16, 2012 09:51AM UTC by ddegasperi comment:6

status: pendingnew

Hi Peter,

a bit of time has passed, but I believe that I used this method to execute javascript when a checkbox/radio button was activated.

It would be nice if there would be a native method, such as "activate" for it.

Changed October 16, 2012 12:43PM UTC by petersendidit comment:7

status: newpending

Are you trying to have "activate" event per button or an "activate" event that is called on the buttonset for when any of the buttons inside of it are clicked? I don't know that we gain much, either you are binding a click event on the button or you are binding on the "activate" event, don't see the value gained. Also when does the "activate" event get triggered, on click? What about buttons the are toggle buttons?

Changed October 17, 2012 07:17AM UTC by ddegasperi comment:8

status: pendingnew
Also when does the "activate" event get triggered, on click?

checkbox/radio buttons can be activated and deactivated, the method "activate" should be triggered when the button is checked.

Changed October 17, 2012 02:51PM UTC by scottgonzalez comment:9

status: newpending

This is still confusing. Events are triggered, not methods. Can you perhaps provide an example of what you would want your code to look like if the API was implemented?

Changed November 01, 2012 09:17AM UTC by trac-o-bot comment:10

resolution: → invalid
status: pendingclosed

Because we get so many tickets, we often need to return them to the initial reporter for more information. If that person does not reply within 14 days, the ticket will automatically be closed, and that has happened in this case. If you still are interested in pursuing this issue, feel free to add a comment with the requested information and we will be happy to reopen the ticket if it is still valid. Thanks!