- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我制作了这样的自定义组件:
my.Cmp = function(opt_domHelper) {
goog.ui.Component.call(this, opt_domHelper);
...
};
goog.inherits(my.Stamina, goog.ui.Component);
my.Cmp.prototype.createDom = function() {
this.decorateInternal(this.dom_.createDom('div', 'сmp-inner-div'));
};
my.Cmp.prototype.decorateInternal = function(element) {
my.Cmp.superClass_.decorateInternal.call(this, element);
var elem = this.getElement();
...
};
my.Cmp.prototype.disposeInternal = function() {
my.Stamina.superClass_.disposeInternal.call(this);
...
};
my.Cmp.prototype.enterDocument = function() {
...
}
my.Cmp.prototype.exitDocument = function() {
...
}
然后我在html文档中创建了一个实例
var cmp = new my.Cmp();
cmp.render(goog.dom.getElement('cmpContainerDivId'));
此组件使用键盘。单击鼠标后它获得键盘焦点并且工作正常。我找不到如何在页面加载后给予 kb 焦点。我试图从 goog.ui.Control 继承 my.Cmp 组件并使用它的 setFocused 方法。 getState() 显示焦点在集合中,但在单击鼠标或按下 Tab 键之前对 kb 键入没有反应。
最佳答案
据推测,具有以下内容:
my.Comp.prototype.setFocused = function(focused) {
goog.base(this, 'setFocused', focused);
if (focused) this.getElement().focus();
};
// ...
goog.events.listen(goog.dom.getWindow(), goog.events.EventType.LOAD, function() {
// ... other init
theCmp.setFocused(true);
});
setFocused()
似乎主要用于簿记,例如 isFocused()
和类似的状态方法。
关于javascript - 如何在页面加载后将焦点设置到 good.ui.Component 或 goog.uiControl 子类组件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10096950/
当我将 goog.require 放入 HTML 文件时.. base.js文件一定要写这样的script标签 然而,当我把一个由 depswriter.py 生成的依赖文件..它不会放置其他文件所
我正在学习 google 闭包,当我尝试使用 goog.ui 组件(其中的任何类)时,出现错误 goog.require 找不到:goog。用户界面。 我的代码是: goog.require('goo
在这段涉及构造函数的 Google Closure javascript 代码片段中,为什么 goog.base(this); 是必需的? Foo 不是已经通过 goog.inherits(foo,
谁能告诉我其中的区别。我刚刚开始关闭谷歌。 最佳答案 goog.provide 创建一个命名空间; goog.require 从给定 namespace “导入”代码,以便闭包编译器可以找到它。 通常
goog.structs 提供了什么而 goog.object 没有提供?我浏览了文档,但没有发现任何令人满意的东西,除了 goog.structs 的第一行说: Generics method fo
更新到 Google Closure Library 的修订版 2156 后,goog.require() 无法找到 goog.ui.AutoComplete。 svn update At revis
我有一个监听 DOM 元素上的事件的 View 类。它还会触发 Controller 监听的事件。 如何才能最好地与 Google Closure 的库配合使用? 这是我最好的镜头。 /** * @
我们正在尝试将项目的打包方式从 dojo 切换到 google 闭包,但到目前为止我们还没有成功。这是一个简单的例子,说明了我们正在努力完成的事情:
我对调用以下代码时发生的情况感到有点困惑: goog.net.XhrIo.send("/welcome", goog.bind(this.handleWelcome, this)); 我有一个带有这个
我正在尝试使用闭包编译器和闭包库。 当我使用该库时,一切正常,我在模拟中包含“base.js”,它适用于我的所有 javascript 文件。 当我“编译”我的应用程序时,问题就出现了:在输出文件中,
我想将 WebGL 与 Google Closure Compiler 结合使用(主要用于三维 View )。我查看了库源代码,但发现 goog.webgl 命名空间中当前只有一个文件,它只做常量值定
来自 Google 的 Closure 库: goog.inherits = function(childCtor, parentCtor) { /** @constructor */ fun
我到处搜索,似乎找不到这个问题的答案:Google 闭包编译器使用 goog.require 函数解析依赖项的顺序是什么。 示例: goog.require('work.Utils'); goog.r
当某些实验标志打开时,我将注入(inject)注册为: 'abcFactory': name.space.createSomeModel 并注入(inject)工厂如下: /** * @param
我正在尝试使用 Google 的 libphonenumber我项目中的库。我正在尝试使用 javascript 版本验证电话号码输入,但它给我一个“goog 未定义”错误。我是 javascript
我想用goog.addSingletonGetter() ( http://closure-library.googlecode.com/svn/!svn/bc/4/trunk/closure/goo
我做了一个 goog.Timer对象 ( http://closure-library.googlecode.com/svn/docs/class_goog_Timer.html ) 与 new go
我使用 Closure Compiler用于在高级模式下测试我的 js 代码的在线工具。 我的代码片段如下: // ==ClosureCompiler== // @compilation_level
我想用google闭包库的goog.module实现JS模块懒加载。 我已经能够通过键入 goog.require(module_name) 来使用这些模块。但是,脚本模块会在开始时以这种方式加载。所
我在我的项目中使用 Google 闭包库和编译器。 下一个字符串出现奇怪的错误: if (!properties.name) { throw {message: 'Widget name ex
我是一名优秀的程序员,十分优秀!