2012-05-05 14 views
2

我需要動態地加載一個複選框,並設置基於某個值的狀態....的Clojure:動態加載的形式在enlive-HTML

這是我迄今所做的......

(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) 
    ) 
) 

但出於某種原因,他們沒有工作...可能是什麼問題....是有沒有辦法在這裏設置複選框狀態.....?

謝謝。

+0

我聽不太懂的背景:在第一個片段,有什麼結果,行,你想用clone-for等來完成什麼?(爲什麼你編號行而不使用數據? ) – cgrand

回答

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))) 

    ) 
) 

)