Is there a way to check whether a JQ widget has already been created on an element? We have a site where the user shifts between different parts of the site, and when they enter one part it creates a jqxSwitchButton. If they leave that part, but then re-visit the section, it recreates the button, including adding a change handler. The issue then is that after the second visit, the handler is called twice (or multiple times with successive visits).
I could create separate code to track button creation, but it’d be simpler code-wise to just check whether a widget is already attached to the element.
EDIT: I realized that I can check for the classes on the element, like
if (!$("#myElement").hasClass("jqx-widget")) {
// create the widget
`}
Is this reliable or is there a better way?