Page 2 of 2

Get value of slider without post

Posted: Mon Nov 04, 2013 10:21 pm
by Branden

I also tried changing the slider to a simple text field. Same problem. It's not capturing the value.

So it seems like I'm experiencing a fundamental problem with capturing values of dynamically generated fields after a button click.

Do you know of any tutorials that make use of this? I feel really stuck.
Thanks!


Get value of slider without post

Posted: Mon Nov 04, 2013 10:25 pm
by maxkatz

Could it be that the component is refreshed (value is reset) and then you read the value?


Get value of slider without post

Posted: Mon Nov 04, 2013 10:32 pm
by Branden

Good question. I don't think so, but let me rule that out for sure. Visually, the value never appears to reset... but let me check into this a bit and get back to you.


Get value of slider without post

Posted: Mon Nov 04, 2013 10:38 pm
by Branden

Here's what I find interesting/confusing, taking another look at the code. Here is the generated HTML of one of my sliders:

code
<input type="number" data-type="range" class="init_slider ui-input-text ui-body-b ui-corner-all ui-shadow-inset ui-slider-input" name="init_slider_0" id="init_slider_0" min="-5" max="30">
/code
But right below that code I see the following:

code
<a href="#" class="ui-slider-handle ui-btn ui-btn-up-b ui-shadow ui-btn-corner-all" data-corners="true" data-shadow="true" data-iconshadow="true" data-wrapperels="span" data-theme="b" role="slider" aria-valuemin="-5" aria-valuemax="30" aria-valuenow="3" aria-valuetext="3" title="3" aria-labelledby="init_slider_label_0" style="left: 22&#46;857142857142858%;"><span class="ui-btn-inner"><span class="ui-btn-text"><&#47;span><&#47;span><&#47;a>
/code

Note the "aria-valuenow" attribute, which contains the actual value I want. I tried to capture it with jQuery, but I don't have an id. In fact, I have no idea where these "aria" attributes are coming from or where the 'a href' is being created. But I think there lies my issue...


Get value of slider without post

Posted: Mon Nov 04, 2013 10:43 pm
by maxkatz

https://developer.mozilla.org/en-US/d...

Try selecting the element right after the input and then finding the 'aria-valuetext' attribute.


Get value of slider without post

Posted: Mon Nov 04, 2013 10:46 pm
by Branden

I was just thinking that. :-) Will try that and let you know how it goes. Thank you for all your patience.