DataTables.net 安全错误”代码:“1000

发布于 2024-10-08 19:38:25 字数 1019 浏览 0 评论 0原文

希望有人能帮我一下......

我设置了 DataTables jquery 插件以在从服务器返回的 json 数据中返回 HTML。行数据的示例如下所示:

["<input type='checkbox' id='2' />","<img src='images/playbtn.png' width='24' height='24' /><a href='javascript:void(0)' onClick='openDialog(0)'>oK5ktqWTOsiyP5wH75tFj2yIY8XprWOwB</a>","11/18/2010 08:16:28 PM","juan j","juan j","incoming","00:02:38","","<img src='images/share.png' class='tableimage' title='Share Call With Friends' /> <img src='images/download.png' class='tableimage' title='Download Call' /> <img src='images/page_edit.png' class='tableimage' title='Edit Call Info' /> <img src='images/trash.gif' class='tableimage' title='Delete Call' />"]

显示工作正常,所有数据都正常返回。

第一个标签的用途是打开 jquery 对话框窗口。我已经正确设置了 jquery 并且我知道它写得正确。但是我的问题是,当我单击 DataTable 单元格内的链接时,没有任何反应,并且我在 firebug 中看到“安全错误”代码:“1000”,我在函数中放入的警报甚至没有触发。我不知道这个错误是什么意思,但一开始我认为这是由于页面上有很多 div 造成的,但我随后制作了一个页面的快速示例,其中仅包含网格和旨在显示的 div出现对话框..这也不起作用。有谁知道为什么数据表会触发这种错误?

谢谢!

Hoping someone can give me a hand here....

I have the DataTables jquery plugin set up to return HTML within the json data coming back from the server. An example of a row's data looks like this:

["<input type='checkbox' id='2' />","<img src='images/playbtn.png' width='24' height='24' /><a href='javascript:void(0)' onClick='openDialog(0)'>oK5ktqWTOsiyP5wH75tFj2yIY8XprWOwB</a>","11/18/2010 08:16:28 PM","juan j","juan j","incoming","00:02:38","","<img src='images/share.png' class='tableimage' title='Share Call With Friends' /> <img src='images/download.png' class='tableimage' title='Download Call' /> <img src='images/page_edit.png' class='tableimage' title='Edit Call Info' /> <img src='images/trash.gif' class='tableimage' title='Delete Call' />"]

The display is working just fine and all the data is coming back nicely.

The purpose of the first tag is to open a jquery dialog window. I have set the jquery properly and I know that it is written correctly. However my problem is that when I click on the link within the cell of the DataTable nothing happens and I see "Security error" code: "1000" in firebug, the alert that I put in the function is not even firing. I do not know what this error means but at first I thought that it was a result of having a lot of div's on the page but I then made a quick example of a page with only the grid on it and the div that is meant to come up as the dialog box..that too did not work. Does anyone know why this kind of error would be triggered by the DataTable?

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

倒数 2024-10-15 19:38:25

我不知道为什么您会收到此安全错误代码,但您可以尝试的一件事是在表格上附加一个单击事件处理程序,并使用事件委托来处理该事件,而不是在表格单元格内添加内联 JavaScript。这是一个例子:

$('table').delegate('a', 'click', function(e) {

    openDialog(0);

    // note: 'this' is the 'a' DOM element, so you can do additional things with it.  For example:
    var $a = $(this);
    var href = $a.attr('href');
    // now do something with href

});

我一直在 DataTables 中使用这种技术,并且效果很好。

I don't know why you're getting this security error code, but one thing you can try instead of adding inline JavaScript inside the table cell is to attach a click event handler on the table and use event delegation to handle the event. Here's an example:

$('table').delegate('a', 'click', function(e) {

    openDialog(0);

    // note: 'this' is the 'a' DOM element, so you can do additional things with it.  For example:
    var $a = $(this);
    var href = $a.attr('href');
    // now do something with href

});

I've been using this technique with DataTables and it works well.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文