monsieurbiz / SyliusRichEditorPlugin

This plugin add a rich editor on fields to be able to drag and drop elements and edit it.
MIT License
65 stars 37 forks source link

Auto-initialise autocomplete fields after opening a dialog #106

Closed DieterHolvoet closed 3 years ago

DieterHolvoet commented 3 years ago

Fixes #105.

DieterHolvoet commented 3 years ago

Do you suggest adding it to the event listener in app.html or to the initUiCollectionForm function in app.js?

maximehuran commented 3 years ago

It can be another method to avoid mess :

initAutoCompleteForm(form) {
    document.dispatchEvent(new CustomEvent('monsieurBizRichEditorInitAutoCompleteForm', {
      'detail': {'form': form}
    }));
  }

Call it when it's needed in app.js.

Then

document.addEventListener('monsieurBizRichEditorInitAutoCompleteForm', (e) => {
        let form = e.detail.form;
        $(form).find('.sylius-autocomplete').autoComplete(); // I don't know if it works
    });
DieterHolvoet commented 3 years ago

What do you think about a more generic monsieurBizRichEditorInitForm event and two subscribers, one for initialising CollectionForm and one for initialising autocomplete.

maximehuran commented 3 years ago

Or a generic event like you said monsieurBizRichEditorInitForm and one event subscriber ^^

DieterHolvoet commented 3 years ago

@maximehuran did the changes, let me know what you think.

maximehuran commented 3 years ago

I made a rebase from master but I cannot force push with lease in your branch. Can you resolve the conflict ?

DieterHolvoet commented 3 years ago

Done!

maximehuran commented 3 years ago

Thank you @DieterHolvoet ! 🥇