我已经成功地使用Kynetx的jQuery UI集成在页面上实现了jQuery UI效果。
然而,我很难在sidetab中获得工作效果。以下是我应用程序的规则。我希望有人能指出我遗漏了什么:
global {
css <<
#tester
{
margin-left: 10px;
margin-top: 10px;
width: 80px;
height: 80px;
background: green;
position: relative;
}
>>;
}
rule tab is active {
select when pageview ".*" setting ()
pre {
results = <<
<div id='tester'></div>
>>;
}
{
sidetab() with pathToTabImage = "http://dl.dropbox.com/u/10762217/search-tab-images/tab2.png"
and tabColor = "transparent"
and topPos = "50px"
and message = results
and divCSS = {
"z-index": 10000,
"backgroundColor": "#ffffff",
"width": "200px",
"padding": "0px",
"imageHeight": "162px",
"imageWidth": "53px",
"-moz-border-radius": "5px"
};
watch("#tester", "click");
}
}
rule jeffect_on_click is active {
select when web click "#tester"
jquery_ui:effect("#tester","bounce","normal");
}
}我确保包括了
use javascript resource jquery_ui_js在我的meta标签里。
发布于 2010-11-30 06:00:46
你不会错过任何东西。目前,运行时,特别是watch()操作使用.live()来注册事件处理程序。sidetab()会吃掉所有附加了.live()的事件处理程序。sidetab()之所以接受它们,是因为.live()实际上是通过将单击处理程序附加到document对象来工作的,然后监视事件是否冒泡。当它到达document时,它检查事件是否是从与您的选择器匹配的元素注册的,如果是,它将触发您的处理程序。sidetab()通过调用event.stopPropagation()来终止它,它停止了事件的冒泡,所以它永远不会到达document,所以你的处理程序永远不会触发。
您可以通过向jQuery实用程序函数.bind()注册事件处理程序来解决此问题。.bind()将只为已经存在的元素注册处理程序,但是只要您注意sidetab内部的元素在调用.bind()之前就存在,就可以了。
如下所示:
$K("#tester").bind("click", function() {
$K(this).effect("bounce", { "times" : 3 }, 300);
});让我们把它放在整个应用程序的上下文中,好吗?
为了保持这个示例简单,我们将简单地emit附加我们的处理程序所需的javascript,并在单击时让div弹出。此示例也是available as a gist
ruleset a369x111 {
meta {
name "Sidetab->Events"
description <<
Sidetab jQuery
>>
author "AKO"
logging on
use javascript resource jquery_ui_js
}
global {
css <<
#tester {
margin-left: 10px;
margin-top: 10px;
width: 80px;
height: 80px;
background: green;
position: relative;
}
>>;
}
rule tab {
select when pageview ".*"
pre {
results = <<
<div id="tester"></div>
>>;
}
{
sidetab() with pathToTabImage = "http://dl.dropbox.com/u/10762217/search-tab-images/tab2.png"
and tabColor = "transparent"
and topPos = "50px"
and message = results
and divCSS = {
"z-index": 10000,
"backgroundColor": "#ffffff",
"width": "200px",
"padding": "0px",
"imageHeight": "162px",
"imageWidth": "53px",
"-moz-border-radius": "5px"
};
emit <|
$K("#tester").bind("click", function() {
$K(this).effect("bounce", { "times" : 3 }, 300);
});
|>;
}
}
} https://stackoverflow.com/questions/4270544
复制相似问题