2013-05-09 54 views
0

我在我的jQuery移动应用程序的标题中有一个刷新按钮,点击事件不会在我的浏览器(Chrome)中触发。这里是我的代码:jQuery Mobile data-role =“header”点击事件未触发

HTML

<div data-role="header" data-position="fixed"> 
    <a id="#refresh_deals" data-role="button" data-inline="true" data-iconpos="notext" data-mini="true" data-icon="refresh"></a> 
    <div data-role="fieldcontain" class="ui-title" data-inline="true"><input id="main_search" data-mini="true" type="search" /></div> 
    <a id="map_btn" data-inline="true" data-mini="true" data-transition="slide" href="#gps_map">Map</a> 
</div><!-- header --> 

的JavaScript

$(document).bind('pageinit', function() { 
    $('#refresh_deals').on('click', function(){ 
     console.log('refresh clicked') 
    }); 
}); 

这是一个非常简单的事情,但没有运气吧!我已经尝试了点击事件以及我可以在网络上找到的其他任何东西。有谁知道这里发生了什么?

+0

尝试.live( '点击', – HaBo 2013-05-09 17:16:11

+0

的'#'你选择告诉jQuery的,它的期待对于一个ID,但是你的id是'#refresh_deals',所以你的选择器需要是'## refresh_deals',或者更可能你的ID只是'refresh_deals'。 – 2013-05-09 17:16:40

回答

1

你的HTML是不正确,请尝试更改此:

<a id="#refresh_deals" ... /> 

这样:

<a id="refresh_deals" ... /> 
+1

OMG!Wow ..显然我需要sleep ......谢谢你Palash。 – PropSoft 2013-05-09 17:18:35