Hello,
I’m building my first plugin and somehow, its not running my JavaScript
Shouldn’t this work?
(function initialize called once per instance when it gets visible)
function(instance, context) {
alert('test');
}
Hello,
I’m building my first plugin and somehow, its not running my JavaScript
Shouldn’t this work?
(function initialize called once per instance when it gets visible)
function(instance, context) {
alert('test');
}
Scope or Timing: In Bubble’s plugin system, the initialize function only gets called once when the element is rendered or becomes visible. If there are conditions affecting whether or not the element is visible, the function may not be called as expected.
Sandboxing: Bubble plugins run in a sandboxed environment. Certain browser behaviors like alert() may not work as expected due to Bubble’s restrictions. Instead, you might want to use console.log(‘test’); to see if the code is actually being triggered.
Missing Event or Hook: Ensure that the element using the plugin is actually loaded and visible. If the element that should trigger the initialize event isn’t being properly rendered or hooked in the DOM, the function won’t fire.
To troubleshoot:
• Replace alert(‘test’) with console.log(‘test’) to verify if the function is being called.
• Check that the element the plugin is tied to is properly initialized and visible in the DOM when the plugin should load.
Are you sure the element is actually visible? I also recommend using a console.log rather than an alert
Thanks,
console.log(‘test’) also does nothing.
Do I have to create any event to make it work?
I have so far not create any
Have you put the element on the page?
yes, its on the page.
Its working now.
I had this unchecked:
After checking it I can see the console.
Thanks for the help!
Solving problems is all part of the process! Glad you figured it out.