Answer the question
In order to leave comments, you need to log in
How to fill progressbar in uikit with jQuery?
Hello, I can't understand why the function doesn't work
Suppose var field = progressBar1
This way, when I call the function and pass the field value through the argument, it doesn't work
function changeProgress (field, typeOperation) {
switch (field) {
case "plus":
field.value += 1;
break;
case "minus":
field.value -= 1;
break;
}
}
function changeProgress (field, typeOperation) {
switch (field) {
case "plus":
progressBar1.value += 1;
break;
case "minus":
progressBar1.value -= 1;
break;
}
}
Answer the question
In order to leave comments, you need to log in
Do you see the joke? You have learned uikit technology and now you have new questions.
The base of the progressbar is that it's two regular divs - one outer and one with padding that you move around based on a variable that changes in real time.
You control a variable, and the variable change event causes your progress bar to change.
Judging by your code, you are trying to change a variable in the handler function that is not set in this function. Before that, you wrote code in which you declared a variable through name = 1; thereby creating a GLOBAL variable that exists everywhere on the page.
And uikit uses var name = 1; creating a LOCAL variable that is accessible within the specific function and its descendants.
In your case, the progressbar is processed using another function that is created (a function in js can also be "perceived as a variable") not in the same place as the progressbar1 variable, so the function does not know about it.
To get around this, there are a couple of options:
1) really change through the field, because as you can see, your progressbar is passed to this function in the field
2) if this confuses you, then you can add changeProgress.call (null, progressbar1) to the call to the changeProgress function ;
The call method CALLS the function, slipping into it what it didn't know ahead of what it knew. Your changeProgress will turn into
and you'll be able to change as you're used to
. In fact, by learning a new technology, you force yourself to get used to how it works, rather than trying to change it. This is the problem of imperfect technology - it comes free of charge, far from the fact that it works well, and requires you to be humble and lack a brain in general - you just use the ready-made one as it is.
Thus, once again, your problem will be solved by:
1) getting used to what is, because this is technology
2) changing what is, but very soon you will realize that the number of changes made is such that it was easier for you to write it from scratch
3) write from scratch right away and don’t sweat it, but then understand that the customer doesn’t want to pay you for “writing from scratch”, because the business coach gave him noodles about “ready-made solutions”, and then you will return to point one and so on in a circle
Look for the position that is most convenient for you - write from scratch and demand money, or use ready-made and not be responsible for the result. Both will make you guilty in the end, which means that, according to the laws of modern lawyers, it is due to your customer (for example, there is a way to "do everything according to the contract" - this is when you say that everything will be fair, but in fact you indicate the clause in the contract about a free license for installed modules, and in court you take such a trump card out of your pocket - I warned him and it’s not my fault that he doesn’t know what a free license for a ready-made solution is, just business, nothing more)
Hence - you choose only customers who understand this and put up with it, realizing that you are the only one who can be responsible for this and therefore you should never be made a fool. Unfortunately, almost all modern customers understand that you are not the only one, so their job is to prove to you that you owe them, and then "work and do not ask for a raise, otherwise there will be a court and you will pay."
Does this mean that it is better not to work for a business at all? For me yes. But growing potatoes and digging a garden, and then getting hooked on a point from the fact that frosts came and the whole crop died - is also a so-so approach. Therefore, you grow up in yourself and be ready to throw your customers as soon as they behave "unworthy", because yes, the customer is also not the only one. The other extreme - "if there was no business" will lead to another level of unemployment, when not a single double-dealer can get a job, they will have to study, and they are too lazy, so they will start robbing in broad daylight. The current solution ensures the absence of a civil war - the doubles are directors, the smart ones are slaves. The smart ones won't take to the square because the smart ones, the double-dealers deceive but don't rob, because there is an opportunity and no one punishes them.
* It doesn't take much to be tech savvy to do simple things, technology has been a means of manipulating people since ancient times, because we have a craving for the unknown.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question