[英]Prototype JS, help detecting form element change
我对原型并不熟悉,但是受命对拾色器进行一些更改。 我进行了大多数更改,没有太多问题。
我需要做的就是监听表单输入。
任何人都可以建议这样做吗?
我找到了这个,但是我不知道如何实现: http : //api.prototypejs.org/dom/form/element/observer/
这是我一直在插件中使用的元素。
实例一
//
// picker sample text
//
this.textValue = document.createElement('input');
this.textValue.type = "text";
this.textValue.name = "textValue";
this.textValue.className = options.textValueClass;
this.header.appendChild(this.textValue);
实例2
setColor: function(color) {
this.textValue.setAttribute('value', color);
this.sample.style.backgroundColor = color;
},
我希望实例3像这样。
if (this.textValue.<<changes>> && this.textValue.<<value.length>> == 7) {
// Check if valid hex
// Trigger Save
}
有人可以帮忙填写<< >>
吗。
参见http://www.prototypejs.org/api/event/observe 。
this.observe('change', this.validateOnChange.bind(this));
validateOnChange: function(event) {
var value;
value = $(this.fieldid).getValue();
if (value.length == 7) {
//Check if valid hex
// Trigger Save
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.