假设您有下表(这里感兴趣的列是cid):
+-----+-------+-------+-------+---------------------+--------------+
| cid | pid | rid | clink | time | snippet |
+-----+-------+-------+-------+---------------------+--------------+
| 155 | 11222 | 1499 | 1137 | 2012-08-22 03:05:06 | hi |
| 138 | 11222 | 241 | 1136 | 2012-08-21 05:25:00 | again |
| 138 | 11222 | 241 | 1135 | 2012-08-21 05:16:40 | hi |
| 155 | 11222 | 1499 | 1134 | 2012-08-21 05:11:00 | hi cute |
| 140 | 11222 | …Run Code Online (Sandbox Code Playgroud) 我将以下内容放在Twitter Bootstrap popover中,其中包含我想要听取点击的链接:
<div id="popover-content">
<a id="link" href="#">click</a>
</div>
Run Code Online (Sandbox Code Playgroud)
我正在使用一个按钮来显示包含上述内容的popover:
<button id="trigger" data-placement="bottom" title="title">Reveal popover</button>
Run Code Online (Sandbox Code Playgroud)
然后我将按钮与popover相关联并使用jQuery的click()函数来尝试监听popover中包含的链接的点击:
$(function(){
$('#trigger').popover({
html: true,
content: function() {
return $('#popover-content').html();
}
});
$('#link').click(function() {
alert('beep');
});
});
Run Code Online (Sandbox Code Playgroud)
但是,在单击按钮以显示弹出窗口然后单击链接时,似乎未按上述方式检测到单击.我对DOM,javascript和jQuery的理解相当有限,所以我不确定这里发生了什么.如何选择/监听弹出窗口中包含的元素的操作?
以下查询对两个表进行操作:dev_Profile和dev_User.
SELECT
dev_Profile.ID AS pid,
Name AS username,
st1.online
FROM
dev_Profile
LEFT JOIN (
SELECT
dev_User.ID,
lastActivityTime /* DATETIME */
FROM
dev_User)
AS st1 ON st1.ID = dev_Profile.UserID;
Run Code Online (Sandbox Code Playgroud)
每个表中大约有11K行,此查询需要大约6秒才能完成.我还没有很多数据库经验.我认为创建一个索引dev_Profile.UserID可以做到这一点,因为dev_Profile.ID已经有一个索引(它是PK)并且dev_Profile.UserID没有索引,但这根本没有帮助.
编辑:此查询的EXPLAIN输出:
+----+-------------+-------------+------+---------------+------+---------+------+-------+-------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+-------------+------+---------------+------+---------+------+-------+-------+
| 1 | PRIMARY | dev_Profile | ALL | NULL | NULL | NULL | NULL | …Run Code Online (Sandbox Code Playgroud)