mirror of
https://github.com/Choices-js/Choices.git
synced 2024-05-21 15:06:45 +02:00
Render callback
This commit is contained in:
parent
2ffda7f8a1
commit
ea7a7c2b22
|
@ -210,7 +210,7 @@ classNames: {
|
|||
}
|
||||
```
|
||||
|
||||
<strong>Usage:</strong> Classes added to HTML generated by Choices.
|
||||
<strong>Usage:</strong> Classes added to HTML generated by Choices. By default classnames follow the [BEM](http://csswizardry.com/2013/01/mindbemding-getting-your-head-round-bem-syntax/) notation.
|
||||
|
||||
### callbackOnInit
|
||||
<strong>Type:</strong> `Function` <strong>Default:</strong>`() => {}`
|
||||
|
|
4
assets/scripts/dist/choices.min.js
vendored
4
assets/scripts/dist/choices.min.js
vendored
File diff suppressed because one or more lines are too long
|
@ -40,7 +40,6 @@ export class Choices {
|
|||
prependValue: null,
|
||||
appendValue: null,
|
||||
loadingText: 'Loading...',
|
||||
logState: false,
|
||||
classNames: {
|
||||
containerOuter: 'choices',
|
||||
containerInner: 'choices__inner',
|
||||
|
@ -69,6 +68,7 @@ export class Choices {
|
|||
callbackOnInit: () => {},
|
||||
callbackOnAddItem: (id, value, passedInput) => {},
|
||||
callbackOnRemoveItem: (id, value, passedInput) => {},
|
||||
callbackOnRender: () => {},
|
||||
};
|
||||
|
||||
// Merge options with user options
|
||||
|
@ -1392,10 +1392,6 @@ export class Choices {
|
|||
|
||||
// Only render if our state has actually changed
|
||||
if(this.currentState !== this.prevState) {
|
||||
// Log state
|
||||
if(this.config.logState) {
|
||||
console.info(this.currentState);
|
||||
}
|
||||
|
||||
// Choices
|
||||
if((this.currentState.choices !== this.prevState.choices || this.currentState.groups !== this.prevState.groups)) {
|
||||
|
@ -1447,6 +1443,14 @@ export class Choices {
|
|||
}
|
||||
}
|
||||
|
||||
if(callback = this.config.callbackOnRender){
|
||||
if(isType('Function', callback)) {
|
||||
callback();
|
||||
} else {
|
||||
console.error('callbackOnRender: Callback is not a function');
|
||||
}
|
||||
}
|
||||
|
||||
this.prevState = this.currentState;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue