Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Web and WebWorks Development

Reply
Developer
Posts: 165
Registered: ‎10-04-2010
My Device: P'9982 & Z10
My Carrier: alfa Lebanon
Accepted Solution

How to dynamically update Slider Position?

I have this Slider element:

<input id="slider" type="range" min="100" max="5000" value="250" step="50"/>

Sometimes, I need to change the value for the user when they go into its screen. The way I'm doing it is this:

document.getElementById("slider").value = sliderValue;

 

However, the slider stays on the 250 value. Even though if I log its value (console.log(document.getElementById("slider").value);), it shows as the updated value but the UI isn't getting updated or something. What do I need to do to fix this!?

 

The function that updates the Slider is called on: ondomready: function(element, id, params) {...} in bb.init()

 

Also, I'm trying to manually edit its value from Chrome's Javascript Console, but that element is null. I'm guessing it's because Ripple loads it as an internal iFrame? Any way to directly access these elements from the Console?

 

I'm not sure if this is similar, but I'm facing a problem with a checkbox as well where document.getElementById('myCheckBox').checked always returns false regarless of the checkbox's state! It's driving me crazy!

Wadi
Highlighted
Retired
Posts: 1,382
Registered: ‎07-02-2009
My Device: BlackBerry Bold 9900
My Carrier: Bell

Re: How to dynamically update Slider Position?

Are you using bbUI.js?  If so, it adds a setValue()  function to the slider elements that "allows the value to be set and also apply the visual styling"

 

https://github.com/blackberry/bbUI.js/wiki/Sliders

 

You can see how this framework is styling the range element dynamically by looking at its source code in Github:

https://github.com/blackberry/bbUI.js/blob/master/samples/bbui.js#L8046-L8069

 

 

Follow me on Twitter: @n_adam_stanley
-------------------------------------------------------------------------------------------------------------------------
Your app doesn't work? Use BlackBerry remote web inspector to find out why.