JqTouch - 检测动画触发器
我在使用 jqTouch 时遇到的另一个问题... 我试图检测单击哪个元素来触发动画,以便我可以将参数从单击的项目传递到后续页面。
我的 HTML 是:
<div id="places">
<div class="toolbar">
<h1>Places</h1>
<a class="back" href="#">Back</a>
</div>
<ul>
<li id="1"><a href="#singleplace">Place 1</a></li>
<li id="2"><a href="#singleplace">Place 2</a></li>
<li id="3"><a href="#singleplace">Place 3</a></li>
</ul>
</div>
<div id="singleplace">
<div class="toolbar">
<h1></h1>
<a class="back" href="#">Back</a>
</div>
</div>
当我单击 #places 中的任何列表项时,我可以很好地滑到 #singleplace,但我试图检测单击了哪个元素,以便我可以将参数传递到 #单位分区我的 javascript 是:
var placeID;
$('#places a').live('mouseup',function(){
$('#singleplace h1').html($(this).text())
placeID = $(this).parent().attr('id');
})
我已经尝试了 $(el).live('event', fn()) 方法的几种替代方法,包括:
$('#places a').live('click',fn()...
$('#places a').live('mouseup',fn()...
$('#places a').live('tap',fn()...
$('#places a').tap(fn()...
似乎都不起作用。我有更好的方法来处理这个问题吗? 我注意到 jqTouch 的问题页面上有这样的内容: http://code .google.com/p/jqtouch/issues/detail?id=91 这可能是问题的一部分......
Yet another problem I'm having w/ jqTouch...
I'm trying to detect what element was clicked to trigger an animation so that I can pass parameters from the clicked item to the subsequent page.
My HTML is:
<div id="places">
<div class="toolbar">
<h1>Places</h1>
<a class="back" href="#">Back</a>
</div>
<ul>
<li id="1"><a href="#singleplace">Place 1</a></li>
<li id="2"><a href="#singleplace">Place 2</a></li>
<li id="3"><a href="#singleplace">Place 3</a></li>
</ul>
</div>
<div id="singleplace">
<div class="toolbar">
<h1></h1>
<a class="back" href="#">Back</a>
</div>
</div>
When I click on any of the list items in #places, I'm able to slide over to #singleplace just fine, but I'm trying to detect which element was clicked so that I can pass parameters into the #singleplace div. My javascript is:
var placeID;
$('#places a').live('mouseup',function(){
$('#singleplace h1').html($(this).text())
placeID = $(this).parent().attr('id');
})
I've tried several alternatives to the $(el).live('event', fn()) approach including:
$('#places a').live('click',fn()...
$('#places a').live('mouseup',fn()...
$('#places a').live('tap',fn()...
$('#places a').tap(fn()...
None of which seem to work. Is there a better way I could be handling this?
I noticed on jqTouch's issues page, there is this: http://code.google.com/p/jqtouch/issues/detail?id=91
which may be part of the problem...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您只是尝试传递单击的列表项的信息,您可以将
onClick="function(event)"
附加到项目...然后在 js 中...
其中 <代码>x.id=='1' x.title==first & x.text=='Place 1'
希望能有所帮助。
If you're just trying to pass info from which list item was clicked, you could attach an
onClick="function(event)"
to the items...then in the js...
where
x.id=='1' x.title==first & x.text=='Place 1'
hope that helps a bit.
我找到了一个解决方案:
tap(function()...)
而不是live('click',function()...)
jQT。 goTo('#singleplace', 'slide');
return false;
这对我有用,甚至在 Firefox 和 Safari 中,而不仅仅是在移动 safari 中。
一些附加信息:
JQTouch 中的实时事件似乎存在问题:http:// /code.google.com/p/jqtouch/issues/detail?id=165
请告诉我这是否也适合您。
I found a solution:
tap(function()...)
instead oflive('click',function()...)
jQT.goTo('#singleplace', 'slide');
return false;
This works for me, even in Firefox and Safari, not only in mobile safari.
Some additional information:
There seems to be a problem with the live event in JQTouch: http://code.google.com/p/jqtouch/issues/detail?id=165
Let me know if this also works for you.