Return value of the init function for custom condition.

Return value of the init function for custom condition.

ryan0987ryan0987 Posts: 2Questions: 1Answers: 0
edited August 2021 in SearchBuilder

Custom Conditions example returns jQuery in the init function, but it seems that it does not work at least for the string type. I wrote the code below, and it didn't work for el, but worked for el[0]. Can you add some comment for this to the example?

conditions: {
    string: {
        "notContains": {
            conditionName: "Not Contains",
            init: function(that, fn, preDefined = null) {
                const el = $('<input/>')
                    .addClass(that.classes.input)
                    .addClass(that.classes.value)
                    .on('input', function() {
                        fn(that, this);
                    });
                return el[0]; // here
            },
            inputValue: function(el, that) {
                return [$(el[0]).val()];
            },
            isInputValid: function(el, that) {
                return $(el).val().trim().length > 0;
            },
            search: function(value, comparison) {
                return value.toLowerCase().indexOf(comparison[0].toLowerCase()) === -1;
            }
        }
    }
}

Answers

Sign In or Register to comment.