mirror of https://github.com/ColorlibHQ/AdminLTE
Small fix for TodoList plugin (#3013)
Properly attach the event listener to the correct selector and fix on the options passed on in the JQuery API. However, a new bug comes from this fix when both data-widget and Jquery API is set where the event listener will be triggered twicepull/3015/head
parent
16b4d30d31
commit
48743c7dee
|
@ -64,7 +64,7 @@ class TodoList {
|
|||
// Private
|
||||
|
||||
_init() {
|
||||
const $toggleSelector = $(SELECTOR_DATA_TOGGLE)
|
||||
const $toggleSelector = this._element
|
||||
|
||||
$toggleSelector.find('input:checkbox:checked').parents('li').toggleClass(CLASS_NAME_TODO_LIST_DONE)
|
||||
$toggleSelector.on('change', 'input:checkbox', event => {
|
||||
|
@ -77,15 +77,18 @@ class TodoList {
|
|||
static _jQueryInterface(config) {
|
||||
return this.each(function () {
|
||||
let data = $(this).data(DATA_KEY)
|
||||
const _options = $.extend({}, Default, $(this).data())
|
||||
|
||||
if (!data) {
|
||||
data = new TodoList($(this), _options)
|
||||
$(this).data(DATA_KEY, data)
|
||||
data = $(this).data()
|
||||
}
|
||||
|
||||
const _options = $.extend({}, Default, typeof config === 'object' ? config : data)
|
||||
const plugin = new TodoList($(this), _options)
|
||||
|
||||
$(this).data(DATA_KEY, typeof config === 'object' ? config : data)
|
||||
|
||||
if (config === 'init') {
|
||||
data[config]()
|
||||
plugin[config]()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue