从Greasemonkey调用时,jQuery UI对话框引发错误 [英] jQuery UI Dialog Throw Errors When Invoked from Greasemonkey

查看:110
本文介绍了从Greasemonkey调用时,jQuery UI对话框引发错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

每次尝试从
Greasemonkey创建一个对话框时,我都会收到这个尴尬的错误...我认为它与
XPCNativeWrapper https://developer.mozilla.org/en/XPCNativeWrapper#Limitations_of_XPCNativeWrapper
,虽然我不是100%确定。

I'm getting this awkward error any time I try and create a dialog from Greasemonkey... I believe it has to do with the limitations of XPCNativeWrapper https://developer.mozilla.org/en/XPCNativeWrapper#Limitations_of_XPCNativeWrapper , though I am not 100% sure.

我使用过的核心jQuery方法都没有导致错误
(追加,css,提交,keydown,每个......) 。

None of the core jQuery methods that I've used have caused errors (append, css, submit, keydown, each, ...).

这可能是Greasemonkey中的错误,或者由于
Greasemonkey和jquery ui之间的交互,但我真的是
有兴趣了解如何让他们一起工作。

It is possible that this could be an error in Greasemonkey or due to the interaction between Greasemonkey and jquery ui, but I am really interested in figuring out how to get them to work together.

// ==UserScript==
// @name           Dialog Test
// @namespace      http://strd6.com
// @description    jquery-ui-1.6rc6 Dialog Test
// @include        *
//
// @require        http://ajax.googleapis.com/ajax/libs/jquery/1.3.1/jquery.min.js
// @require        http://strd6.com/stuff/jqui/jquery-ui-personalized-1.6rc6.min.js

// ==/UserScript==

$(document).ready(function() {
 $('<div title="Test">SomeText</div>').dialog();
});

错误:
[例外...组件不可用nsresult:0x80040111
(NS_ERROR_NOT_AVAILABLE)location:JS frame ::
file:///home/daniel/.mozilla/firefox/.../components/greasemonkey.js ::
anonymous: :第347行数据:否]
[中断此错误] if(line){

Error: [Exception... "Component is not available" nsresult: "0x80040111 (NS_ERROR_NOT_AVAILABLE)" location: "JS frame :: file:///home/daniel/.mozilla/firefox/.../components/greasemonkey.js :: anonymous :: line 347" data: no] [Break on this error] if (line) {

Firefox版本:
Mozilla / 5.0(X11) ; U; Linux i686; en-US; rv:1.9.0.6)Gecko / 2009020911
Ubuntu / 8.04(hardy)Firefox / 3.0.6

Firefox version: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.6) Gecko/2009020911 Ubuntu/8.04 (hardy) Firefox/3.0.6

更新:标准jQuery库中的focus()方法也会抛出相同的错误:

Update: The focus() method from the standard jQuery library also throws the same error:

$('body').focus();

也许UI在某个时候调用焦点方法?

Maybe the UI is calling the focus method at some point?

任何帮助都将不胜感激!

Any help will be greatly appreciated!

推荐答案

这个线程很老但是使用Greasemonkey的方法Jquery to focus()是向jquery对象添加[0]以将其转回DOM元素。

This thread is pretty old but the way to use Greasemonkey with Jquery to focus() is to add a [0] to the jquery object to turn it back to a DOM element.

      //Example:  
      $('#obj').focus();                          //Does not work
      document.getElementById('obj').focus();     //Works

      //Hybrid:
      $(#obj)[0].focus();                         //Work around

这篇关于从Greasemonkey调用时,jQuery UI对话框引发错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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