jQuery UI Selectmenu question
I am using
jQuery UI Selectmenu. I am not sure if this plugin is an "official" UI plugin and belongs here, but hope it does.
I have a table with multiple rows, and a select menu in each row.
Upon change of the select menu, I store some info in the DB. As such, I want to prompt the user to confirm that the change should be made, and if not, revert to the original select menu status. My plan was to use a click event to always store the original select value.
- $('.className').click(function() { select_cache=$(this).val(); });
- $('.className').change(function() {
- if(confirm('Are you sure?')) {alert('post data to server');}
- else {alert('change back to value'+select_cache);}
- });
This approach seems to work only if the user selects the menu by clicking on the up/down arrows, and not by clicking on the menu text. Any suggestions?
By the way, selectmenu doesn't appear to work correctly with current jQueryUI. To get it working, I had to make the following changes to
Replace
- _init: function() {
With
- widgetEventPrefix: "selectmenu",
- options: {
- transferClasses: true,
- style: 'popup',
- width: null,
- menuWidth: null,
- handleWidth: 26,
- maxHeight: null,
- icons: null,
- format: null,
- errorClass: 'ui-state-error ui-selectmenu-error'
- },
- _create: function() {
Replace
- this.newelement.prepend('<span class="'+self.widgetBaseClass+'-status">'+ selectOptionData[this._selectedIndex()].text +'</span>');
With
- this.newelement.prepend('<span class="'+self.widgetBaseClass+'-status">'+ this._selectedIndex() +'</span>');
Add the following line at the end of destroy().
- $.Widget.prototype.destroy.call( this );
Replace
- _setData: function(key, value) {
With
- _setOption: function(key, value) {
Replace
- $.extend($.ui.selectmenu, {
- getter: "value",
- version: "@VERSION",
- eventPrefix: "selectmenu",
- defaults: {
- transferClasses: true,
- style: 'popup',
- width: null,
- menuWidth: null,
- handleWidth: 26,
- maxHeight: null,
- icons: null,
- format: null
- }
- });
With
- $.extend($.ui.selectmenu, {
- version: "@VERSION",
- });