Dojo mobile and callback in dojox.mobile.ListItem

淺唱寂寞╮ 提交于 2019-12-11 11:13:36

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!