Muhammad Kamal
Muhammad Kamal

Reputation: 344

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.

Upvotes: 0

Views: 314

Answers (2)

sorenbryder
sorenbryder

Reputation: 145

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

Upvotes: 3

head
head

Reputation: 1

May be your database.js is loaded before the dom a totaly loaded.

So i suggest to add a event onload to your body to load the Constructor or init function.

//jquery

$(document).ready(function(){
      //INIT CONSTRUCTOR FUNCTION
  });

//JS
document.body.onload = function(){
   //INIT CONSTRUCTOR FUNCTION  
};

Upvotes: 0

Related Questions