</style>
<script type="text/javascript">
$(function(){
- var speedA = $('select#speedA').selectmenu(
- );
+ var speedA = $('select#speedA').selectmenu();
- $("#getValue").click(function(event){
+ $("#index").click(function(event){
+ console.log($('select#speedA').selectmenu("index"));
+ });
+ $("#indexNumber").click(function(event){
+ console.log($('select#speedA').selectmenu("index", 4));
+ });
+ $("#value").click(function(event){
console.log($('select#speedA').selectmenu("value"));
});
- $("#setValue").click(function(event){
+ $("#valueString").click(function(event){
+ console.log($('select#speedA').selectmenu("value", "Medium"));
+ });
+ $("#valueNumber").click(function(event){
console.log($('select#speedA').selectmenu("value", 4));
});
+ $("#valueNumberAsString").click(function(event){
+ console.log($('select#speedA').selectmenu("value", "11"));
+ });
+ $("#valueNonExisting").click(function(event){
+ console.log($('select#speedA').selectmenu("value", "test123"));
+ });
});
</script>
- <!--
- <script type="text/javascript" src="http://ui.jquery.com/applications/themeroller/themeswitchertool/"></script>
- <script type="text/javascript"> $(function(){ $('<div style="position: absolute; top: 20px; right: 10px;" />').appendTo('body').themeswitcher(); }); </script>
- -->
</head>
<body>
<br />
<br />
<form action="#">
- <a href="#nogo" id="getValue">getValue</a>
- <a href="#nogo" id="setValue">setValue to 4</a>
+ <a href="#nogo" id="index">method index without paramaters (get index)</a><br />
+ <a href="#nogo" id="indexNumber">method index with paramater '4' (set index by number)</a><br />
+ <a href="#nogo" id="value">method value without paramaters (get value)</a><br />
+ <a href="#nogo" id="valueString">method value with paramater 'Medium' (set value by string)</a><br />
+ <a href="#nogo" id="valueNumber">method value with paramater '4' (passed as number)</a><br />
+ <a href="#nogo" id="valueNumberAsString">method value with paramater '11' (passed as string)</a><br />
+ <a href="#nogo" id="valueNonExisting">method value with paramater 'test123' (not existing value)</a>
<br />
<h2>"default popup" Style</h2>
<fieldset>
<option value="Medium">Medium</option>
<option value="Fast">Fast</option>
<option value="Faster">Faster</option>
+ <option value="11">Up to eleven</option>
</select>
</fieldset>
</form>
.mouseup(function(event){
if(self._safemouseup){
var changed = $(this).data('index') != self._selectedIndex();
- self.value($(this).data('index'));
+ self.index($(this).data('index'));
self.select(event);
if(changed){ self.change(event); }
self.close(event,true);
if(this.element.attr('disabled') == true){ this.disable(); }
//update value
- this.value(this._selectedIndex());
+ this.index(this._selectedIndex());
// needed when selectmenu is placed at the very bottom / top of the page
window.setTimeout(function() {
this._prevChar[0] = C;
},
_uiHash: function(){
- var index = this.value();
+ var index = this.index();
return {
index: index,
option: $("option", this.element).get(index),
.attr('aria-hidden', true)
.removeClass(this.widgetBaseClass+'-open');
if(this.options.style == "dropdown"){ this.newelement.removeClass('ui-corner-top').addClass('ui-corner-all'); }
- console.log(this.newelement);
- console.log(this.retainFocus);
if(retainFocus){this.newelement.focus();}
this._trigger("close", event, this._uiHash());
}
.attr("aria-disabled", value);
}
},
- value: function(newValue) {
+ index: function(newValue) {
if (arguments.length) {
this.element[0].selectedIndex = newValue;
this._refreshValue();
+ } else {
+ return this._selectedIndex();
+ }
+ },
+ value: function(newValue) {
+ if (arguments.length) {
+ // FIXME test for number is a kind of legacy support, could be removed at any time (Dez. 2010)
+ if (typeof newValue == "number") {
+ this.index(newValue);
+ } else if (typeof newValue == "string") {
+ this.element[0].value = newValue;
+ this._refreshValue();
+ }
+ } else {
+ return this.element[0].value;
}
- return this.element[0].selectedIndex;
},
_refreshValue: function() {
var activeClass = (this.options.style == "popup") ? " ui-state-active" : "";