mirror of
https://github.com/wagtail/wagtail.git
synced 2024-11-25 05:02:57 +01:00
Add mechanism for retrieving an existing widget instance from ChooserFactory
This commit is contained in:
parent
d534567f81
commit
67ff655111
@ -20,6 +20,9 @@ export class Chooser {
|
||||
this.clear();
|
||||
});
|
||||
}
|
||||
|
||||
// attach a reference to this widget object onto the root element of the chooser
|
||||
this.chooserElement.widget = this;
|
||||
}
|
||||
|
||||
initHTMLElements(id) {
|
||||
@ -72,6 +75,10 @@ export class Chooser {
|
||||
}
|
||||
}
|
||||
|
||||
setStateFromModalData(data) {
|
||||
this.setState(data);
|
||||
}
|
||||
|
||||
clear() {
|
||||
this.setState(null);
|
||||
}
|
||||
@ -127,7 +134,7 @@ export class Chooser {
|
||||
);
|
||||
}
|
||||
this.modal.open(this.getModalOptions(), (result) => {
|
||||
this.setState(result);
|
||||
this.setStateFromModalData(result);
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -170,4 +177,9 @@ export class ChooserFactory {
|
||||
const options = { ...this.getModalOptions(), ...customOptions };
|
||||
this.modal.open(options, callback);
|
||||
}
|
||||
|
||||
getById(id) {
|
||||
/* retrieve the widget object corresponding to the given HTML ID */
|
||||
return document.getElementById(`${id}-chooser`).widget;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user