typo3typo3-flowneoscms

Typo3 Neos Cannot Load Custom Plugin JS On Backend, Must Refresh To Make It Works


i'm trying to load my custom plugin on backend, e.g. datatables.js. But the JS is not working, i must refreshing the page once to make it works, there is also no error on the backend webbrowser console. How to solve this?

Any help would be much appreciated! thanks.


Solution

  • I don't think you should use document ready as this event is only fired once in the backend (unless you refresh the entire be). Instead you should use Neos.PageLoaded.

    if (typeof document.addEventListener === 'function') {
        document.addEventListener('Neos.PageLoaded', function(event) {
            // Do stuff
        }, false);
    }
    

    You can find documentation here: http://docs.typo3.org/neos/TYPO3NeosDocumentation/IntegratorGuide/InteractionWithTheNeosBackend.html