QueryBuilder is not a function error!!
See original GitHub issueHello - Query Builder is perfectly work on my page. but if i am try below code in my external .JS its showing “Query Builder is not a function” error
and below code perfectly working in my “CustomRule.aspx” Page
<script src="../plugins/jquery/jquery.min.js"></script>
<link href="../plugins/querybuilder2/bootstrap-select.css" rel="stylesheet" />
<link href="../plugins/querybuilder2/query-builder.default.min.css" rel="stylesheet" />
<link href="../plugins/querybuilder2/bower_components/selectize/dist/css/selectize.bootstrap3.css" rel="stylesheet" />
<script src="../plugins/querybuilder2/bootstrap.min.js"></script>
<script src="../plugins/querybuilder2/query-builder.standalone.min.js"></script>
<script src="../plugins/querybuilder2/bower_components/interact/interact.js"></script>
<script src="../plugins/querybuilder2/bower_components/bootbox/bootbox.js"></script>
<script src="../plugins/querybuilder2/bower_components/selectize/dist/js/standalone/selectize.min.js"></script>
<script src="../plugins/querybuilder2/bower_components/sql-parser/browser/sql-parser.js"></script>
<script>
function SetUnit(query) {
var $q = new $.Deferred();
var oData = [];
var filter = JSON.stringify({ 'param': query });
$.ajax({
type: "POST",
url: '../WebService.asmx/ExecuteReader',
contentType: "application/json; charset=utf-8",
data: filter,
dataType: "json",
}).fail(function (jqXHR, textStatus, errorThrown) {
$q.reject(jqXHR, textStatus, errorThrown);
console.log('Reject...', jqXHR);
}).done(function (data, textStatus, jqXHR) {
$q.resolve(data, textStatus, jqXHR);
console.log('Completed Done!!.....', data);
}).progress(function () {
console.log('in processing.....');
});
return $q.promise();
}
; (function ($) {
//var filter = JSON.stringify({ 'param': query });
//$.ajax({
// type: "POST",
// url: '../WebService.asmx/ExecuteReader',
// contentType: "application/json; charset=utf-8",
// data: filter,
// dataType: "json",
// async: true,
// success: function (responce) {
// oUNIT_NAME = jQuery.parseJSON(responce.d);
// },
// error: function (xhr, status, err) {
// console.log(xhr);
// },
//}).then(function () {
//});
$('[data-toggle="tooltip"]').tooltip();
var $b = $('#builder');
var options = {};
var query = "SELECT UnitID as id,Unit as name FROM [dbo].[T_UNIT_ID]";
SetUnit(query).done(function (responce, textStatus, jqXHR) {
options = {
allow_empty: true,
//default_filter: 'name',
sort_filters: true,
optgroups: {
core: {
en: 'Group', en: 'Clam', en: 'Group',
en: 'Provider', en: 'Group', en: 'Group'
}
},
plugins: {
'bt-tooltip-errors': { delay: 100 },
//'sortable': null,
'filter-description': { mode: 'bootbox' },
//'bt-selectpicker': null,
'unique-filter': null,
'bt-checkbox': { color: 'primary' },
'invert': null,
'not-group': null
},
// standard operators in custom optgroups
operators: [
{ type: 'equal', optgroup: 'basic' },
{ type: 'not_equal', optgroup: 'basic' },
{ type: 'in', optgroup: 'basic' },
{ type: 'not_in', optgroup: 'basic' },
{ type: 'less', optgroup: 'numbers' },
{ type: 'less_or_equal', optgroup: 'numbers' },
{ type: 'greater', optgroup: 'numbers' },
{ type: 'greater_or_equal', optgroup: 'numbers' },
{ type: 'between', optgroup: 'numbers' },
{ type: 'not_between', optgroup: 'numbers' },
{ type: 'begins_with', optgroup: 'strings' },
{ type: 'not_begins_with', optgroup: 'strings' },
{ type: 'contains', optgroup: 'strings' },
{ type: 'not_contains', optgroup: 'strings' },
{ type: 'ends_with', optgroup: 'strings' },
{ type: 'not_ends_with', optgroup: 'strings' },
{ type: 'is_empty' },
{ type: 'is_not_empty' },
{ type: 'is_null' },
{ type: 'is_not_null' }
],
filters: [
{
id: 'Unit',
label: 'UNIT NAME',
type: 'string',
input: 'select',
multiple: true,
plugin: 'selectize',
plugin_config: {
valueField: 'name',
labelField: 'name',
searchField: 'name',
sortField: 'id',
options: JSON.parse(responce.d)
},
operators: ['in', 'not_in', 'is_null', 'is_not_null'],
valueSetter: function (rule, value) {
rule.$el.find('.rule-value-container select')[0].selectize.setValue(value);
}
},
{
id: 'PLAN_NM',
label: "PLAN Name",
value_separator: ',',
type: 'string',
optgroup: 'core',
size: 30,
validation: { allow_empty_value: false },
},
],
};
// init
$('#builder').queryBuilder(options);
});
$('#builder').on('validationError.queryBuilder', function (e, rule, error, value) {
console.log('Warning : ', error);
$('#btnUpdateQuery').addClass('hidden');
$('#btnInqueryRule').addClass('hidden');
$('#sqlResult').css('display', 'none').html('');
swal({
title: "Filter not validate!!",
text: error,
type: "warning",
showCancelButton: false,
closeOnConfirm: true
});
});
$('#builder').on('afterCreateRuleInput.queryBuilder', function (e, rule) {
if (rule.filter.plugin == 'selectize') {
rule.$el.find('.rule-value-container').css('min-width', '200px')
.find('.selectize-control').removeClass('form-control');
}
});
// set rules from SQL
// reset builder
$('.reset').on('click', function () {
$('#builder').queryBuilder('reset');
$('#sqlResult').css('display', 'none').html('');
});
$('#btnExecRule').on('click', function () {
var res = $('#builder').queryBuilder('getSQL', $(this).data('stmt'), false);
var queryStr = res.sql + (res.params ? '\n\n' + JSON.stringify(res.params, undefined, 2) : '');
$('#sqlResult').css('display', 'block');
$('#sqlResult').html(queryStr);
$('#btnUpdateQuery').removeClass('hidden');
$('#btnInqueryRule').removeClass('hidden');
});
})(jQuery);
</script>
Issue Analytics
- State:
- Created 6 years ago
- Comments:7 (3 by maintainers)
Top Results From Across the Web
Uncaught TypeError: $(...).queryBuilder is not a function #623
any jquery event like document.ready/buttonclicks throws the error : Uncaught TypeError: $(...).queryBuilder is not a function ...
Read more >JQuery QueryBuilder not working - Stack Overflow
But when I use the same inside $(document).ready(function(){...}, I still get the same error. I need to add an onclick listener to the...
Read more >TypeError: query is not a function - Esri Community
Solved: Hello, I wanted to get html elements for a class using dojo/query within then() of queryTask. Please see below.
Read more >Plugins - jQuery QueryBuilder
This configuration is stored in the mongoOperators and mongoRuleOperators options, the keys are the operators types and the values are formatting functions, see ......
Read more >JavaScript: Uncaught TypeError: n is not a function
This error occurs if you try to execute a function that is not initialized or is not initialized correctly. This means that the...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I don’t know how your website works I can’t help you on that. Looks perfectly fine on my side.
Problem find but i don’t have a solution…
my all code in this block
; (function ($) {
})(jQuery);
if i am add my SetQuery Function in this block its working but if i am call this function out of this scope its not work… and if i am remove this block then my complete plugin is not work…
its work like this - but i need to call red selected function in my other JS file … Please Help if possible this is your plug in you understand well if i am trying to resolved. i need lot of time because i need to review all code…
PLEASE HELP IF POSSIBLE …