不绑定keyup,而绑定值变化
This commit is contained in:
parent
9609aef740
commit
15da10001b
18
resources/js/vendor/picomplete/picomplete.js
vendored
18
resources/js/vendor/picomplete/picomplete.js
vendored
@ -1,7 +1,7 @@
|
||||
export default class PickleComplate {
|
||||
/**
|
||||
*
|
||||
* @param {object} obj as tree object
|
||||
*
|
||||
* @param {object} obj as tree object
|
||||
*/
|
||||
constructor(obj = null) {
|
||||
//set config
|
||||
@ -10,7 +10,7 @@ export default class PickleComplate {
|
||||
this.req_params = obj.request;
|
||||
//target element
|
||||
this.element = null;
|
||||
//static data
|
||||
//static data
|
||||
this.container = obj.data;
|
||||
//list div element
|
||||
this.sug_div = null;
|
||||
@ -30,7 +30,7 @@ export default class PickleComplate {
|
||||
staticEvents() {
|
||||
// key up event
|
||||
document.querySelectorAll(this.config.target+' input').forEach(e => {
|
||||
e.addEventListener('keyup', el => {
|
||||
e.addEventListener('input', el => {
|
||||
if(this.config.changeCallback !== undefined && this.config.changeCallback!== null) this.config.changeCallback(el.target);
|
||||
if(el.target.value.trim().length>0){
|
||||
this.element = el.target;
|
||||
@ -85,7 +85,7 @@ export default class PickleComplate {
|
||||
|
||||
|
||||
async getSuggests(el) {
|
||||
|
||||
|
||||
//check container type
|
||||
if(this.config.type === 'server'){
|
||||
await this.getData(el.value.toLowerCase());
|
||||
@ -112,8 +112,8 @@ export default class PickleComplate {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//add list to input
|
||||
|
||||
//add list to input
|
||||
if(this.sug_div !== null) this.element.parentNode.appendChild(this.sug_div);
|
||||
}
|
||||
|
||||
@ -121,7 +121,7 @@ export default class PickleComplate {
|
||||
|
||||
/**
|
||||
* this method will send request to given parameters and return list of results
|
||||
* @param {string} value
|
||||
* @param {string} value
|
||||
*/
|
||||
async getData(value){
|
||||
//define if parameters is not defined
|
||||
@ -152,7 +152,7 @@ export default class PickleComplate {
|
||||
|
||||
/**
|
||||
* system request method
|
||||
* @param {json object} rqs
|
||||
* @param {json object} rqs
|
||||
*/
|
||||
async request(rqs, reqCallback = null) {
|
||||
let fD = new FormData();
|
||||
|
Loading…
x
Reference in New Issue
Block a user