var radialObj = radialIndicator('#'+properties.id+'');
$("#" + properties.id).change(function() { radialObj.animate(80); });
But when the value changes, I have to reload the entire page to see the new value. It doesn’t “live” update.
Is there any way to listen to my element value property (properties.value) and if that value changes do the update. Instead of listening to the element?
I mean if I can listen to value change somehow instead of listening to the element because I believe the value when changes it doesn’t reflect on the element, but in the value.
Edit: Tried to do what you told for discard that might causing the issue (Is… this wrapped in something? Javascript doesnt do echoing in this fashion.) And set a static text on the ids, but same. Only updates after reload page.
My question actually is: What event I should use to add a listener to a value and call actions when that value changes.
The element ‘changes’ when its value changes. The two things you’ve said are identical.
You’ve got two canvas elements there - are you drawing the buttons with another canvas? Or has this script been initialized more than once?
Here’s a codepen that implements what the documentation says that matches what you seem to be trying to do:
(Note: The pen includes the minified version of the radialIndicator.js file, ignore lines 1-8 in the javscript, and scroll to the bottom of that window to see the implementation)
The first one uses a class selector, the second one uses an element selector. You can use id selectors too, or any other value valid CSS-based selector to select an element.
What is the HTML for the input field that you want to select?
What you mean “What is the HTML for the input field”?
And s/value/valid?
With the code you sent me i did this, but not sure how to complete it and if its correct:
var thediv = document.getElementById(properties.id);
thediv.addEventListener("input", function (evt) {
$('#'+properties.id+'').data('radialIndicator').animate(properties.value);
});
I dont know what to put where “input”.
My html only has this:
What you mean “What is the HTML for the input field”?[/quote]
It’s equivalent to when someone is having trouble with the grammar of a paragraph they’re working on. Instead of dealing with general principles, it’s best to actually see the paragraph in question so that specific help can be provided.
I made a mistake in my post by saying value. When I edited my post I placed an edit note at the end of my post to say that I substituted value for the more appropriate word of valid.
Using s/value/valid is a cheeky programmer shortcut from a Linux editor called VIM to convey that information, which was popular on other discussion places like IRC. I’m showing my age there.
That HTML does not have a valid id attribute. You need to fix that problem first before you can successfully move on to other things.
Thanks, I’m studying your codepen. Thank you for that.
Do you think its possible to do exactly what you did, but instead of 2 buttons, an input field (without button). And the javascript runs when the value of the input is changed? Without a button, because I don’t want a click fire action.
The library allows you to specify a format for your numbers - if left unset, you’ll see the numbers go a little unreadable as it puts in numbers that are not-quite-whole numbers (an issue with how floating point numbers are stored), so you’ll see like… 1.0000000000000000 on the dial (and you’ll see the middle “00000000” bit).
You can (according to the documentation) submit format as a string, such as “$###,###.##”, in which the #'s will be replaced, or you can provide a function.
In my case, i wrote a function that takes the value, and applies .toFixed(2), a javascript default function Number.toFixed(n) that renders the number as a n-decimal-point floating point. Thus it displays 0.00, up to 100.00, but it wont show 1.000000000.
Basically, I did it to look pretty while it’s animating.