访问Tapestry 5.3.6中的Tapestry JavaScript对象(以前是$ T,现已弃用)

时间:2013-04-29 09:16:05

标签: javascript tapestry

我正在使用Tapestry 5.3.6。我正在迁移一个具有组件的应用程序,该组件具有JavaScript部分,在此JS部分中,我需要访问具有变量$T的Tapestry对象。但是这个变量现在已经弃用了,我怎么能以其他方式做到这一点呢?我需要准确访问表单输入的fieldEventManager

目前我的代码如下:

handleSubmit : function(domevent) {
    var t = $T(this.form);
    t.validationError = false;
    var firstErrorField = null;

    // Locate elements that have an event manager (and therefore, validations)
    // and let those validations execute, which may result in calls to recordError().
    this.form.getElements().each(function(element) {
        var fem = $T(element).fieldEventManager;
        if (fem != undefined) {
            // Ask the FEM to validate input for the field, which fires
            // a number of events.
            var error = fem.validateInput();
            if (error && ! firstErrorField) {
                firstErrorField = element;
            }
        }
    });

1 个答案:

答案 0 :(得分:1)

我认为没有直接替换$T,但看起来getFieldEventManager()方法已直接添加到通过Prototype形成输入。

调整你的功能:

handleSubmit : function(domevent) {
    var t = $(this.form);
    t.validationError = false;
    var firstErrorField = null;

    // Locate elements that have an event manager (and therefore, validations)
    // and let those validations execute, which may result in calls to recordError().
    t.select("input").each(function(element) {
        var fem = element.fieldEventManager;
        if (fem != undefined) {
            // Ask the FEM to validate input for the field, which fires
            // a number of events.
            var error = fem.validateInput();
            if (error && ! firstErrorField) {
                firstErrorField = element;
            }
        }
    });

有关详细信息,第830行tapestry.js的{​​{1}}定义了以下内容:

T5.3.6