Hi All,
I've successfully done many client & suitelet scripts, plus 1 or 2 custom portlets. I'm now trying my hand at a custom HTML portlet. The portlet loads correctly, all the HTML is displayed properly, and I am not a noob to HTML or javascript.
I'm trying to provide some additional simple client-side functions without creating new client scripts in NetSuite. The problem I'm having is that these functions contained in the HTML seem to 'unload' from the browser once the portlet has finished loading/refeshing.
Here is an example of my portlet's main function...
function portletMain(portlet, column) {
[INDENT]var htmlString = "<div id='myCustomPortletDiv'>"
+" <script language='javascript'>"
+" function myCustomFunction() { alert('Hello World'); }"
+" myCustomFunction();" /// THIS CALL TO myCustomFunction WORKS
+" </script>"
+" <input type='button' value='Click Me' onclick='alert(\"click event\"); myCustomFunction();'> "
+" </div>"
portlet.setHtml(htmlString);
[/INDENT]
}
When the portlet is loaded (or refreshed) a "Hello World" alert is correctly displayed from the call to 'myCustomFunction();'. When the user clicks the button, a "click event" alert is displayed BUT the "Hello World" does not pop up. Looking through the javascript console in the browser I see the error message "myCustomFunction is not defined".
So, (as with all questions I end up posting) is this an issue/limitation in NetSuite, did I miss the thread containing the answer, or am I doing something incorrectly?? I've tried in multiple browsers, workstations, and operating systems and get the same results in all.