在内容级使用谷歌Chrome扩展时,没有定义DP_jQuery_ * [英] DP_jQuery_* is not defined when using with google chrome extension at content level

查看:120
本文介绍了在内容级使用谷歌Chrome扩展时,没有定义DP_jQuery_ *的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发Google Chrome扩展程序。
我试图在现有网页(内容级别)的jquery-ui对话框中使用jquery-ui datepicker

I'm developing a google chrome extension. I am trying to use the jquery-ui datepicker inside a jquery-ui dialog of the existing webpage (content level)

像这样:截图

我得到DP_jQuery_1274168529407未定义当我点击datepicker小部件的任何按钮,我认为这是因为jquery datepicker添加到html:

I get "DP_jQuery_1274168529407 is not defined" when I click on any button of the datepicker widget and I think that it's because jquery datepicker adds on the html:

onclick="DP_jQuery_1274192751418.datepicker._selectDay('#new\\-app\\-date',4,2010, this);return false;"

这意味着我必须更改datepicker库以避免修改html,而是附加一个事件在每个obj这样:

This means i'll have to change the datepicker library to avoid modifying the html but rather attach an event on each obj like this:

.click(function(){DP_jQuery_1274192751418.datepicker._selectDay('#new\\-app\\-date',4,2010, this);return false;})


推荐答案

在第8307行的函数_updateDatepicker中修改jquery-ui.js的代码,方法是插入:

Modifying code of jquery-ui.js in function _updateDatepicker at line 8307 by inserting:

.find('[onclick]').each(function(){
    var command = $(this).attr('onclick')+'';
    $(this).removeAttr('onclick');
    command = command.replace("function onclick(event) {","");
    command = command.substr(0, command.length-2);
    $(this).click(function(){eval(command);});
})
.end()

将解决这个问题。

我知道这是丑的
我知道它可以用更少的行
完成但是只是暂时的,直到jquery ui团队修复这个

I know it's ugly I know it can be done with fewer lines But it's just temporary until the jquery ui team fixes this

这篇关于在内容级使用谷歌Chrome扩展时,没有定义DP_jQuery_ *的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆