【问题标题】:dynamic binding in CoffeeKupCoffeeKup 中的动态绑定
【发布时间】:2012-03-05 15:22:26
【问题描述】:

我正在使用 node.js 和 coffee-script 和 coffeekup 作为模板引擎编写一个应用程序。我有一个表单,我想根据某些输入字段中是否有值来启用或禁用按钮。我想知道是否有像 Sproutcore 或 Ember 这样的简单机制,只需绑定即可。我该怎么办?

【问题讨论】:

    标签: node.js coffeescript express coffeekup


    【解决方案1】:

    不,没有这种开箱即用的绑定。你必须要么实现 Ember、Knockout 或 Serenade.js 之类的东西,要么自己动手。如果只是这一种形式,我只需要一个小脚本(下面是 jQuery):

    function validateForm() {
      // Check if form fields are valid, return true if valid, false if not.
    }
    
    // Update the disabled attribute on a button inside "formId" anytime an input field is changed.
    $("#formId").on("change", "input", function(event) {
      $("#formId button").attr("disabled", !validateForm());
    });
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-10-29
      • 1970-01-01
      • 1970-01-01
      • 2011-02-04
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多