-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Hi,
I want to call JavaScript function via init method in the ViewModel, It always throw an error "onLoad is not defined".
my jsTest.js :
function onLoad(){
alert("Hello");
}
my test.zul :
<div apply="org.zkoss.bind.BindComposer"
viewModel="@id('vm') @init('com.test.TestViewModel'>
<script type="text/javascript" src="jsTest.js"></script>
</div>
and myViewModel :
@Init
public void init(){
Clients.evalJavaScript("onLoad()");//Throws an error
}
but if I try called the function via button onClick event it will run just fine.
@command
public void callFunction(){
Clients.evalJavaScript("onLoad()");//No error
}
Pls Help,
Regards, Klepon
Hello!
1 - i'd put also the ; char inside the Clients.evalJavaScript("onLoad();"); 2 - Try to move the <script> tag before the
Giovanni
Asked: 2016-06-14 07:32:53 +0800
Seen: 43 times
Last updated: Jun 14 '16
Facing issue in masking on phone [closed]
coerceFromString_ override no longer works from 6.5.1 [closed]
Execute Javascript on component visible
Is there a way to resolve view model properties as input to client side javascripts?
scrollbar listner for 2 grid [closed]
Theme javascript wpd file not found