Opened 9 years ago

Closed 7 years ago

#5554 closed feature (invalid)

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');

Change History (10)

comment:1 Changed 7 years ago by Jörn Zaefferer

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.

comment:2 Changed 7 years ago by Scott González

Type: enhancementfeature

comment:3 Changed 7 years ago by Scott González

Milestone: TBD1.11.0

comment:4 Changed 7 years ago by bchiasson

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

comment:5 Changed 7 years ago by petersendidit

Owner: set to 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.

comment:6 Changed 7 years ago by ddegasperi

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.

comment:7 Changed 7 years ago by petersendidit

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?

comment:8 Changed 7 years ago by ddegasperi

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.

comment:9 Changed 7 years ago by Scott González

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?

comment:10 Changed 7 years ago by trac-o-bot

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!

Note: See TracTickets for help on using tickets.