geliz zhang
Posts: 0
Joined: Fri Jul 18, 2014 1:22 am

how to customize an event in a page and trigger it

If I have a chat program which in the background keep listening to the network, when new data is coming, how do I notify the page to update? I don't want to reload the whole page.

For a normal html page, I can define an event in the js file like this
function update()
{
//do some update
}
then call this function. But in appery, I can only define the event code within one control object, or if I modify the .js file it's no longer sync to the IDE.

Evgene Karachevtsev
Posts: 12
Joined: Mon Apr 28, 2014 1:12 pm

how to customize an event in a page and trigger it

Hello Geliz,

Please look here. It is the documentation about how you can add the JS to your project:
http://devcenter.appery.io/documentat...

geliz zhang
Posts: 0
Joined: Fri Jul 18, 2014 1:22 am

how to customize an event in a page and trigger it

No. Add js in the project result in that js file is attached onto all of the pages, but I only need a certain page to have it loaded.
Other methods can only apply js to a control, not an independent level.

Yurii Orishchuk
Posts: 0
Joined: Fri Feb 14, 2014 8:20 am

how to customize an event in a page and trigger it

Hi Geliz,

You can use "page load" and "page show" events in accordance to your needs.

See details on screen shot how to do it:

http://prntscr.com/451uxs/direct

Regards.

geliz zhang
Posts: 0
Joined: Fri Jul 18, 2014 1:22 am

how to customize an event in a page and trigger it

Thanks but if I add the code to page load, after its execution the code is no longer in the memory. What I need is a standby code that run in the background, and jump out to so something (for example when receiving a command from the network) do some updating in the page.

For example a weather forecast app, when there is a weather alert, a popup window comes out. This requires the background code to notify the page to update, but there is no such a way to send a notification into a page to trigger an event.

I now use an invisible button to trigger its click event, but if there is a way to define a function in page scope and call that function directly it will be more straight.

Yurii Orishchuk
Posts: 0
Joined: Fri Feb 14, 2014 8:20 am

how to customize an event in a page and trigger it

Hi Geliz,

Do you want have some function invoked by timer?

If so please use following jS code in "page load" JS event handler:

pre

var onInterval = function(){
//Here is you can place code you need

console.log("Interval work.");

};

//Set inverval for 5s.
setInterval(onInterval, 5000);

/pre

Regards.

geliz zhang
Posts: 0
Joined: Fri Jul 18, 2014 1:22 am

how to customize an event in a page and trigger it

No it should not be triggered by timer but network message event.
For example
var onIncomingMessage = function ()
{
//do some work
};
and in a global .js file, in the initialize part of the network module set the trigger
SomeObj.onIncomingMessage = Appery("MainScreen").onIncomingMessage;
Is that possible?

Yurii Orishchuk
Posts: 0
Joined: Fri Feb 14, 2014 8:20 am

how to customize an event in a page and trigger it

Geliz,

yes it could be implemented with Appery.io platform in the same way as other web application.

This event should be invoked by some logic(your own or external 3rd party).

Regards.

Return to “Issues”