You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When saving in the Craft.ElementEditor hud it would be helpful for other JavaScript to be able know that that has happened.
For my current use-case I am building some more live preview tools that work inside a field type and whilst I can do similar things to the core Craft.LivePreview class in terms of regularly checking if field content has changed, I can’t do anything about updating my previews when someone clicks save in an element editor hud.
I have created a PR to illustrate the sort of behaviour I am after: #2688
Steps to reproduce
Navigate to an entry with an element field attached
Select an element and save it on the field
Double-click the element once its on the field to edit, then press save
Additional info
Craft version: 2.6.3014
PHP version: 7.1.x
The text was updated successfully, but these errors were encountered:
Garnish.on(Craft.BaseElementEditor,'saveElement',callback);// later, if you need to disable the event handlerGarnish.off(Craft.BaseElementEditor,'saveElement',callback);
The callback method will get called any time anyCraft.BaseElementEditor fires a saveElement event. So you don’t need to have a handle on the element editor instance ahead of time.
Make sure callback is the exact same function reference if you do in fact need to call Garnish.off() at some point.
As an example, I also updated the Craft.LivePreview class to use this method, rather than Craft.BaseElementEditor being the one to notify Live Preview when an element is saved: 6c52ddb
Description
When saving in the
Craft.ElementEditor
hud it would be helpful for other JavaScript to be able know that that has happened.For my current use-case I am building some more live preview tools that work inside a field type and whilst I can do similar things to the core
Craft.LivePreview
class in terms of regularly checking if field content has changed, I can’t do anything about updating my previews when someone clicks save in an element editor hud.I have created a PR to illustrate the sort of behaviour I am after: #2688
Steps to reproduce
Additional info
The text was updated successfully, but these errors were encountered: