问题
Have anyone tried to use jQUery UI Spinner that uses array as its source data? Basically what I really want to achieve is I have a list of data (in array with string values), I want my spinner to just spin only with those array values. Hope someone could show me how to do it.
回答1:
Ok, I think I'm going to answer my own question, just for the sake for other people who might have the same issue.
var dlist = ['banana','papaya','apple']
$( ".spinner" ).spinner({
min: 0,
max: 2,
create: function(){
$(this).parent().append('<input class="spinner-text" value="'+dlist[$(this).val()]+'">');
},
stop: function(event,ui) {
$(this).siblings('.spinner-text').val(dlist[$(this).val()]);
}
});
You can see how I did it in here
来源:https://stackoverflow.com/questions/25981586/spin-jquery-ui-spinner-from-array-values