as you may already know I'm new to jQuery, so Code-Improvements not belonging to this theme are still very allowed.
This is my HTML-Code:
<div style="display: inline-block; width: 120px;">
<div>
Bananas:
<br />
<input id="bananas_amount" />
<input id="bananas_amount_percent" />
</div>
<br />
<div id="bananas" style="height:200px;"></div>
</div>
And this is my horrifying js-code:
$( "#bananas" ).slider({
orientation: "vertical",
range: "min",
min: 0,
max: 100,
value: 20,
step: 5,
slide: function( event, ui ) {
$( "#bananas_amount_percent" ).val( ui.value + " %" );
// the code displays a percentage by standart, but I need the real value, too:
var bananas_amount_percent = $( "#bananas_amount_percent" ).val();
var bananas_amount_percent = bananas_amount_percent.replace(" %", "");
var bananas_amount = Math.round((weight / 100) * bananas_amount_percent);
$( "#bananas_amount" ).val( bananas_amount + " g" );
}
});
$( "#bananas_amount_percent" ).val( $( "#bananas" ).slider( "value" ) + " %" );
// again the real value (else the value would not be updatet on reload-reset)
var bananas_amount_percent = $( "#bananas_amount_percent" ).val();
var bananas_amount_percent = bananas_amount_percent.replace(" %", "");
var bananas_amount = Math.round((weight / 100) * bananas_amount_percent);
$( "#bananas_amount" ).val( bananas_amount + " g" );
(weight is 200)
However, it's working, except one "little" detail: not with the mousewheel! I already found out that I need this extension: https://github.com/brandonaaron/jquery-mousewheel/downloads
But I've really absolutely no idea how to implement this to my Slider (I've 5 on my Site btw).
Help pls, Thx!