November Happy Hour will be moved to Thursday December 5th.
November Happy Hour will be moved to Thursday December 5th.
So after stepping through tons and tons of epi js code, I found out that the this.editing is being set (what appears to be) when the widget is focused. It does set editing to true, but when attaching to the "change" event, the startediting function of the _EditorWrapperBase js file gets hit after my onChange call happens. therefor, for some reason this.editing in _EditorWrapperBase is false.
This all works if i fire my _onInputWidgetChanged on a blur event for the select2 box. I'm not sure why or how that's possible, but the auto save happens when i blur the select2... I'd like to be able to do this on the change event of select2 because it fires whenever a selection is added or removed...
I'm guessing the this.editing issue is because stopEditing of _EditorWidgetBase happens when i select an option from the dropdown that is created (maybe the select2 is getting blurred when i click the selection, causing stopEditing to fire, then the Change event of select2 happens, then the re-focus of the textbox happens, causing the startEditing to fire.. I wish i could define in my widget when startediting and stopediting happen. or at least override default functionality.
Anyone have any ideas?
I've fixed together a hacky solution, hopefully someone is able to respond with another option
I added
setTimeout(lang.hitch(this, function () {
this.onChange(value);
}), 50);
around the OnChange call with a small timeout, this appears to work, as this.editing for the wrapper base gets set to true before this gets called.
I've also added a blur listener to select2 to call the onChange as well as an added measure just in case this save doesn't fire for whatever reason (since it is hacky)
Does anyone know of a better way to do this, or a way to set this.editing for the wrapper base before my onChange call? I am really skeptical of my solution.
So, this solution isn't working 100% - i'm having intermittent issues with editors not seeing the value save (perhaps they are too quick sometimes and the timeout didn't occur to call change, etc) what i would really like, is a way to force epi to save, regardless of the this.editing check in the base widget class, or at least force editing to be true on the field.
I'm in dire need of a better solution, please help :(
Hi,
I'haven't used the Select2 widget but I'm guessing it opens a "dialog" of some sort when you click on it, and therefor your dojo widget looses focus.
If that is the case you can try to mixin the "epi-cms/widget/_HasChildDialogMixin" on your widget and set the this.isShowingChildDialog to true when the Select2 widgets displays it's options. By setting the isShowingChildDialog to true the dojo widgets does not fire the onBlur event when it looses focus.
Hey Magnus,
Not a dialog, but yes you are correct, when the autocomplete drop down opens and the user clicks on a selection, I beileve the focus is lost on the widget instance which in turn probably fires the onblur and sets editing to false (sometimes stepping through the js doesn't yield the exact same results) but if a user hits enter or uses arrow keys to select something, usually the onChange firing will allow the autosave to go through.
I'm going to give the isShowingChildDialog a whirl when the dropdown opens and closes and see if that allows me to get around the saving issues i'm having.
Thanks!
Hey Guys,
So i've developed a dojo editor for a string property that basically makes a multiselect autocomplete and stores the value in the string as a comma seperated list. Everything is working properly (control shows, value setters are hit, although no values exist because its not being saved, events are hit, this.OnChange is hit and bubbles up to the epi widgets) but the value never saves, stepping through the unminified epi js code, I see where it should be doing a .save but it never hits. In one portion of the code i saw where it as evualating 3 coditions, one of which was this.editing, this was false, which sent it past the .save call...
I've included my dojo code below.. a note, I had to use a jquery plugin (select2) to get the interface i desired, since nothing like this exists for dojo or nobody has created a working version. Again, this loads fine, and works, no issues with jquery, no issues with the values being set on the input it changes into the "fancy multiselect autocomplete" - the only issue is the autosave never happens...
Dojo Code: