Clojure:在enlive-html中加载动态表单

时间:2012-05-05 07:54:50

标签: clojure

我需要动态加载一个复选框,并根据某个值设置其状态....

这就是我到目前为止所做的......

(defsnippet customer-config-setup html-customer-configuration [:div#div_game_setup_container ]
  [result-rows]
  [:div#div_gameprefix]
  (clone-for [idv (map vector (iterate inc 0) result-rows)]
    [:button#btn_gameprefix ]
    (do->

    #(if (= (result-rows :active) 0)
       ((set-attr :checked  :val )%)%)
      (content (str ((idv 1) :gameprefix )))

    )
  )

)

以及

(defsnippet customer-config-approval html-customer-configuration [:div#div_auto_approval ]
  [result-rows]
  [:tr#tr_auto_approval]
  (clone-for [idv (map vector (iterate inc 0) result-rows)]
    [:td#td_auto_approvaltext ] (content (str ((idv 1) :settings_caption )))
    [:td#td_auto_checkbox ] (set-attr :checked  :val )
    )
  )

但由于某种原因他们不起作用......可能是什么问题......有没有办法在这里设置复选框状态.....?

谢谢..

1 个答案:

答案 0 :(得分:0)

对不起,我错过了什么.. 在这里获取值时添加(((idv 1))是必要的...我真的没有足够的时间来挖掘并找到原因甚至需要...因为library/clojure资源如此之低和教程很难找到这样的事情的理由......

(defsnippet customer-config-setup html-customer-configuration [:div#div_game_setup_container ]
  [result-rows]
  [:div#div_gameprefix]
  (clone-for [idv (map vector (iterate inc 0) result-rows)]
    [:button#btn_gameprefix ]
    (do->

    #(if (= (((idv 1)result-rows :active)) 0)
       ((set-attr :checked  :val )%)%)
      (content (str ((idv 1) :gameprefix )))

    )
  )

)