Reputation: 35
I'm trying to create a spinner that shows a formatted float. The formatter only works after spin event. Is there any way to format it on stop event?
This is my code:
<script src="/files/recursos/globalize/lib/globalize.js"></script>
<script src="/files/recursos/globalize/lib/cultures/globalize.cultures.js"></script>
<script src="/files/recursos/globalize/lib/cultures/globalize.culture.es.js"></script>
<script>
$( "#input_importe" ).spinner({
step: 0.01,
culture: "es",
numberFormat: "n2",
min: 0
});
//EVENTS
$( "#input_importe" ).spinner({
spin: function( event, ui ) {
console.log("SPIN");
$( "#input_importe" ).spinner("value", ui.value);
},
stop: function( event, ui ) {
current = $( "#spinner" ).spinner( "value");
console.log('STOP ' + current);
$( "#spinner" ).spinner( "value", current );
}
});
I'm using Globalize.js (v 0.1.1) and it works correctly when I use the spin, but I need to format the value when I put it manually in the input box (on stop event).
FE: 1.005,23
Any ideas?, thanks for your help.
Upvotes: 2
Views: 748
Reputation: 11
I would suggest using the following command in order to refresh the culture and apply the appropriate format: $(this).spinner( "option", "culture", "es");
Upvotes: 0