我有一个ASP.net MVC2应用程序。在此我使用JQuery来更改所有表格行,以便我可以单击任意行中的任意位置来触发单击行中链接上的单击事件。IE中的JQuery错误,适用于FF。也许生活中有问题
这些表格是使用内置在partialview ajax中的MVC创建的。
这是我的JQuery脚本。
<script type="text/javascript">
$(document).ready(function() {
$('table tr').live('click',function (event) {
$('#asplink', this).trigger('click');
})
.live('mouseenter',function (event) {
this.bgColor = 'lightblue';
})
.live('mouseleave', function (event) {
this.bgColor = 'white';
});
});
</script>
这是创建表的部分视图代码的第一部分。
<% foreach (var item in Model.JobHeaderData)
{ %>
<tr>
<td>
<a id="asplink" href="http://localhost/sagstyring/EditJob.asp?JobDataID=<%: item.JobDataId %>&JobNumId=<%: item.JobNumID%>&JobNum=<%: item.JobNumID%>&DepId=1&User_Id=<%:ViewData["UserId"]%>" onclick="window.open(this.href,'Rediger sag <%: item.JobNumID %> ', 'status=0, toolbar=0, location=0, menubar=0, directories=0, resizeable=0, scrollbars=0, width=900, height=700'); return false;">Rediger</a>
</td>
在Firefox中,这个作品完美。在IE中,当我点击一行时,JQuery崩溃。
如果我在IE中调试页面。我明白了。
Out of stack space
在jQuery的1.4.1.js线1822
// Trigger the event, it is assumed that "handle" is a function
var handle = jQuery.data(elem, "handle");
if (handle) {
handle.apply(elem, data);
}
我在JavaScript的没有老鹰,所以我非常坚持。
编辑:IE浏览器在我的window.open函数中有一个空格问题,点击事件。修复后,我现在可以看到click事件正在工作,但它进入循环。我只是不断点击链接,直到出现堆栈空间错误。
对此有何看法?
同样的错误。在JQuery中的不同位置它失败了。 线1593 如果(!手柄){ \t \t \t eventHandle =函数(){ \t \t \t \t //处理的触发的第二事件,并且当被调用 \t \t \t \t //事件在页面卸载后 \t \t \t \t return typeof jQuery!==“undefined”&&!jQuery.event.triggered? \t \t \t \t \t jQuery.event.handle.apply(eventHandle.elem,自变量): \t \t \t \t \t未定义; \t \t \t}; \t \t \t handle = jQuery.data(elem,“handle”,eventHandle); \t \t} – olve 2010-05-10 07:08:22
出于好奇:如果你只是调用.click()而不是.trigger('click'),会发生什么 另外:我刚刚注意到:#asplink是一个ID为asplink的选择器。你的网页上有多个相同的ID?这可能是什么扔IE浏览器。 – Patricia 2010-05-10 15:04:14
刚刚尝试使用.click而不是触发器。它仍然在FF中工作,但在IE中我得到一个“对象不支持这个属性或方法”,但点击事件仍然执行。我的表中的每一行都会有一个具有相同ID的链接。如果我将其更改为类,则会发生内存不足错误。 – olve 2010-05-11 11:27:25