问题
I'm a dojo newbie and have encountered this problem in mobile version: I try to use callback with javascript function, but it wont work.
What am I doing wrong?
<script>
function My_function(){
alert("Hello");
}
</script>
<div id="homepage_view" data-dojo-type="dojox.mobile.View">
<h1 data-dojo-type="dojox.mobile.Heading">Mobile....</h1>
<ul data-dojo-type="dojox.mobile.RoundRectList">
<li data-dojo-type="dojox.mobile.ListItem"
data-dojo-props='moveTo:"whereIam_view",
transition:"slide",
callback:"My_function()",
'>sth....</li>
<li data-dojo-type="dojox.mobile.ListItem"
data-dojo-props='moveTo:"places_aroud_me_view",
transition:"slide"'>sth else....</li>
<li data-dojo-type="dojox.mobile.ListItem"
data-dojo-props='moveTo:"places_in_koszalin_view",
transition:"slide"'>sth even more else....</li>
</ul>
</div>
Thanx for help in advance.
回答1:
You could use reference instead of function name string. Instead of:
function My_function(){
alert("Hello");
}
Use:
functionName = function My_function(){
alert("Hello");
}
And then inside the prop
data-dojo-props='moveTo:"whereIam_view",
transition:"slide",
callback:functionName,
'>sth....</li>
Remember! Without the quotes around the functionName
来源:https://stackoverflow.com/questions/13008629/dojo-mobile-and-callback-in-dojox-mobile-listitem