FriendsOfTYPO3 / frontend_editing

TYPO3 CMS Frontend Editing
https://friendsoftypo3.github.io/frontend_editing/
102 stars 38 forks source link

Update Editor Events for Ajax Content #318

Closed ZweisteinT closed 5 years ago

ZweisteinT commented 5 years ago

Hello,

when adding typo3 content via Ajax, for instance like this:

function getContent(element, url) {
    $.ajax({
        url: "http://" + window.location.hostname + url + "?type=5",
        dataType: "html",
        success: function (html_content) {
            $(element)
                .css("display", "none")
                .html(html_content)
                .fadeIn();
        }
    });
}
getContent("#course_presentation", "/deutsch/gruppenkurs/standardkurs");

Then those new Content Elements are not editable. To clarify that: They are indeed editable, the box becomes orange and i can edit the text. But: The save button doesnt realize that the Content was changed. Therefore i cant save it.

My question: How can i update the JS FrontendEditor to get the Events right? I hoped for something like this, but i dont know how to use "require":

require(['FrontendEditing'], function (foo) {
            FrontendEditing.refreshIframe();
        });
MattiasNilsson commented 5 years ago

Have you tired using the namespace instead TYPO3/CMS/FrontendEditing?

ZweisteinT commented 5 years ago

I dont know what your question means.

Maybe someone is interested in a Workaround: I check if the Website is in Frontend Mode: var Editing = $('.t3-frontend-editing__ce').length > 0 ? 1 : 0;

When it is in editing mode, i just reload the Website with the Ajax called synced: async: false

Then the frontend Editor can use ist typical "onLoad" Events to find all editable Content Elements. When not using the frontend Editor, the Website is still fully Ajax enabled of Course.

Idea to fix it: Give us a update() funtion we can call.

anjeylink commented 5 years ago

@ZweisteinT see #341