Opened 13 years ago
Closed 10 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 11 years ago by
comment:2 Changed 11 years ago by
Type: | enhancement → feature |
---|
comment:3 Changed 10 years ago by
Milestone: | TBD → 1.11.0 |
---|
comment:4 Changed 10 years ago by
Summary: | button with method activate → Button: Provide an "activate" event/callback |
---|
comment:5 Changed 10 years ago by
Owner: | set to ddegasperi |
---|---|
Status: | new → pending |
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 10 years ago by
Status: | pending → new |
---|
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 10 years ago by
Status: | new → pending |
---|
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 10 years ago by
Status: | pending → new |
---|
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 10 years ago by
Status: | new → pending |
---|
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 10 years ago by
Resolution: | → invalid |
---|---|
Status: | pending → closed |
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!
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.