わかりました、私は最終的にこれを私が望んでいた方法で行うことができました。JQueryUI からスピナーを拡張する currencyspinner という名前のプラグインを作成しました。コードは次のとおりです。
$.widget( "ui.currencyspinner", $.ui.spinner, {
options: {
numberFormat: 'C', // Currency Format
min:0,
step:0.10
},
_create: function(){
this.hidden = $('<input type="hidden" value="'+this.element.val()+'" name="'+this.element.attr('name')+'">'); // Create a hidden input with the same name and value
this.element.removeAttr('name'); // remove the name of the original element
this.element.before(this.hidden); // insert the hidden element before the original element
return this._super();
},
_refresh: function() {
this.hidden.val(this._parse(this.element.val())); // put the aria-valuenow on the original element
return this._super();
},
_destroy: function(){
this.element.attr('name',this.hidden.attr('name')); // put back the name on the original value
this.hidden.remove(); // remove the hidden element
return this._super();
}
});
同じ名前の非表示の入力を作成し、スピナーが更新されるたびに aria-valuenow の値を与えます。
currencyspinner を作成した後で currencyspinner にアクセスしようとしている場合は、使用できないことに注意$('input[name="nameoftheelement"]').currencyspinner(...);
してください。これは、スピナー自体ではなく非表示の入力になるためです。
私はそれが誰かを助けることを願っています!