Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add bindChange and getValue to jqFilter #214

Open
emielJ opened this issue Dec 9, 2011 · 1 comment
Open

Add bindChange and getValue to jqFilter #214

emielJ opened this issue Dec 9, 2011 · 1 comment

Comments

@emielJ
Copy link

emielJ commented Dec 9, 2011

When creating filters with complex UI elements (for instance date-time input which consists of two separate input fields, of when the text that was entered has to be processed before it can be used in a filter (for instance convert the input of a date field into a JavaScript Date object) it would be nice to have alternative ways to get the value from the input or to attach the on change event on a different way than the default way.

In order to accomplish this, I have created the following functions:

function getValue($element, p) {
    if ($.isFunction(p.getValue)) {
        return p.getValue($element, p);
    }
    return $element.val();
}

function bindChange($element, p, change) {
    if ($.isFunction(p.bindChange)) {
        return p.bindChange($element, p, change);
    }
    return $element.bind('change', change);
}

These functions can be used to replace the calls to

rule.data = $(this).val();

into

rule.data = getValue($(this), that.p);

and the binding of the change events like

$(".input-elm",trpar).bind('change',function() { ...

into

bindChange($(".input-elm", trpar), that.p, function () { ...

Of course the values getValue and bindChange must be copied from the searchGrid options during the call in which jqFilter is created.

@tonytomov
Copy link
Owner

Hello,
I will consider this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants