2017-08-10 86 views
0

我有一个关于条件和Hoplon的问题。当我尝试:Clojurescript与Hoplon和单元格不工作的条件语句

(defn mouse-enter 
    [temp stuff] 
    (reset! temp @stuff) 
    (if (= "y" "y") 
     (reset! mon-width {:width "0%"}))) 

它将CSS宽度属性更改为0,但是,如果我尝试以任何方式尝试使用单元格似乎不工作。 IE浏览器。

(def week-view (cell "y")) 
(def mon-width (cell {:width "50.333%"})) 

(defn mouse-enter 
    [temp stuff] 
    (reset! temp @stuff) 
    (if (= "y" (cell= week-view)) 
     (reset! mon-width {:width "0%"}))) 

或者:

(defn mouse-enter 
    [temp stuff] 
    (reset! temp @stuff) 
    (if (= "y" (str (cell= week-view))) 
     (reset! mon-width {:width "0%"}))) 

或者:

(defn mouse-enter 
    [temp stuff] 
    (reset! temp @stuff) 
    (when (= "y" (str (cell= week-view))) 
     (reset! mon-width {:width "0%"}))) 

或者:

(defn mouse-enter 
    [temp stuff] 
    (reset! temp @stuff) 
    (when (= (cell= "y") (cell= week-view)) 
     (reset! mon-width {:width "0%"}))) 

而这一次的作品,即使周视图的值发生了变化。

(def week-view (cell "n")) 
(def mon-width (cell {:width "50.333%"})) 

(defn mouse-enter 
    [temp stuff] 
    (reset! temp @stuff) 
    (when (= (str (cell= "y")) (str (cell= week-view))) 
     (reset! mon-width {:width "0%"}))) 

我真的不知道是怎么回事,但我只是想在“周视图”设置为“Y”,以获得真正有条件的积极。我尝试过布尔运算,但似乎没有工作,还有很多其他的东西。

干杯, 马特

回答

1

我想我想通了。您可以使用@符号来获取单元格的值。这是可用的新代码。

(def week-view (cell nil)) 
(def mon-width (cell {:width "8.333%"})) 

(defn mouse-enter 
    [temp stuff] 
    (reset! temp @stuff) 
    (when (= nil @week-view) 
     (reset! mon-width {:width "30%"}))) 

干杯, 马特

+0

您也可以考虑包装既'复位!'的'dosync'调用。这会导致重置作为单个“交易”一起发生。它现在不一定修复任何错误,但会让你的代码更容易思考。 –