Problem:
Greetings,
I added jquery.js and my script.js to the resources. In script.js I do this kind of call:
jQuery (’. button’). on (‘click’, function () {
alert (‘click’);
});
I have associated the “button” class to an element of the document, but the click event is not executed.
I verified that both script.js and jQuery.js are imported correctly by checking with the javascript console of Google Chrome.
Script files in Resources are executed before creating scenes and elements.
So there’s no element with button class at that time.
You can change your script as follows to make it work:
jQuery(document).on('click', '.button', function () {
alert('click');
});
Another way is defining functions in script files and call them in Saola Animate event handlers when scene elements are already created (e.g. in Scene Activate event)
A thousand thanks!
I am testing Saola Animate to find a valid alternative to the old “Adobe Edge Animate CC 2015”, which we are still using in my team. So far Saola Animate seems like a great product to me, congratulations!
Saola Animate creates elements dynamically, it doesn’t ensure that elements are created before window load event. So your approach may work for one project but not work for others.
A trivial example is a project with two scenes and the first scene has animations, the second scene will be created after window load event.