Closed starlino closed 3 years ago
Why would number
be undefined
? If you provide a valid input
field it will always have a value.
This actually happens in CS-Cart that uses your library. I think during some animation/ switching the filed becomes briefly unavailable. It also might have to do with timeouts and de-synchronized calls. Anyways in real world this can happen unfortunately since DOM is not set in stone. I think it would be useful to do a sanity check for undefined since it will trigger an error and interrupt execution of the rest of the script. Just good coding practice , not a requirement. Thanks.
Ah, OK. That makes sense. What do you think the behaviour should be in that case?
Also, do you have an example of a page where it happens?
I think all you have to do is check that $(_this) still exists. You can use the code I provide above (since it is verified to work), or just check that $(_this).size() > 0 , or better yet 'undefined' != typeof $(_this).val()
Thanks. I’ll look into this.
Temporary workaround: