2
Good morning, I’m trying to use Jquery’s Querybuilder along with Vuejs, but I’m getting the following error:
Below follows the code that is giving this error:
this.$refs.builder.queryBuilder({
filters: [{ id: 1 }]
});
Previously I used Angularjs, and worked perfectly with this code:
angular.element('#builder').queryBuilder({
filters: [{ id: 1 }]
});
It also works with Jquery:
$('#builder').queryBuilder({
filters: [{ id: 1 }]
});
This is the HTML code:
<div id="builder" ref="builder"></div>
Does anyone know why it doesn’t work in Vuejs?
Wouldn’t it be more interesting to use a tool in Vue instead of using jQuery within a Vue project? Ex.: Vue-query-Builder.
– fernandosavio
Not to mention that
this.$refs.builder
refers to an HTML element and not to a jQuery object as you might be thinking. You could convert to a jQuery object using$(this.$refs.builder)
but I don’t know if the plugin instance will be linked to the object.– fernandosavio
I also thought about it, but since we have a team, the staff thought it best to continue with this Querybuilder, because the system already has other screens implemented with it, and the developers are already used to it. I just ran into this problem because we are making a migration from Angularjs to Vuejs.
– Brayan
$(this.$refs.builder).queryBuilder(...)
worked?– fernandosavio
Oops, it worked yes! Thank you very much! Want to insert as answer to the question?
– Brayan
I’m going to insert now.
– fernandosavio