Elxis CMS Forum

Support => Elxis 4.x/5.x DEV => Topic started by: datahell on May 13, 2019, 22:09:26

Title: Use page loader in Elxis 5.x
Post by: datahell on May 13, 2019, 22:09:26
Let's say you have a javascript function that performs an AJAX task and you want during this process to display a "Please wait" message. You can use  elx5StartPageLoader and elx5StopPageLoader to do so. The elx5StartPageLoader function has an input parameter with which you can define your own page loader. In this example we will use the administration's area default page loader for simplicity.

To begin page loader:
elx5StartPageLoader();

When you script ends (with success or failure it doesnt matter) stop the page loader like this:
elx5StopPageLoader();

That's it! Easy enough?

In case you want to create your own page loader. The in PHP type this:

echo $elxis->obj('html')->pageLoader('mypgloader');
where mypgloader is the ID of your page loader.

Then in javascript you call it like this:
elx5StartPageLoader('mypgloader');
elx5StopPageLoader('mypgloader');