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

Can add target element to callback? #67

Open
liubusian opened this issue Apr 17, 2018 · 0 comments
Open

Can add target element to callback? #67

liubusian opened this issue Apr 17, 2018 · 0 comments

Comments

@liubusian
Copy link

Sometimes it is necessary to change the style under different results, just like success and error

So, I added in:

data = that.ajax.preProcess(data);

to:

data = that.ajax.preProcess(data, this.$element);

other:

var params = this.ajax.preDispatch ? this.ajax.preDispatch(query) : {
query: query
};

var params = this.ajax.preDispatch ? this.ajax.preDispatch(query, this.$element) : {
                    query: query
                };

if (this.options.onSelect) {
this.options.onSelect({
value: value,
text: text
});

if (this.options.onSelect) {
      this.options.onSelect({
           value: value,
           text: text
       }, this.$element);
}

Now, I can change icon after loading

preProcess(data, elem){
    if(data.success){
        return data;
    }else{
        $(elem).addClass('valid-error');
    }
}

A little suggestion,
Thanks

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

No branches or pull requests

1 participant