[ClojureScript] Re: [Reagent, React] value of select/option's attribute is incorrect.

2015-03-30 Thread Bin Li
On Monday, March 30, 2015 at 11:56:39 PM UTC+8, Francis Avila wrote:
> Generally the React elements mirror dom objects rather than html tags and 
> attributes.
> 
> For example, :multiple and :selected are booleans, not strings.
> 
> 
> Also, the select element has a value property you can set directly instead of 
> messing with :selected. 
> https://facebook.github.io/react/docs/forms.html#why-select-value
> 
> Code should be more like:
> 
> (defn duallist [] 
>   [:div.row 
>[:div.col-md-7 
> [:select {:multiple true
>   :value ["option2" "option3"]
>   :size "10" 
>   :name "duallistbox_demo" 
>   :class "demo" 
>   :style {:display "none"}} 
>  [:option {:value "option1"} "Option 1"] 
>  [:option {:value "option2"} "Option 2"] 
>  [:option {:value "option3"} "Option 3"] 
>  [:option {:value "option5"} "Option 5"] 
>  ] 
> ] 
>] 
>   ) 
> 
> 
> On Monday, March 30, 2015 at 5:32:54 AM UTC-5, Bin Li wrote:
> > I created this reagent component:
> > 
> > (defn duallist []
> >   [:div.row
> >[:div.col-md-7
> > [:select {:multiple "multiple"
> >   :size "10" 
> >   :name "duallistbox_demo"
> >   :class "demo"
> >   :style {:display "none"}}
> >  [:option {:value "option1"} "Option 1"]
> >  [:option {:value "option2" :selected "selected"} "Option 2"]
> >  [:option {:value "option3" :selected "selected"} "Option 3"]
> >  [:option {:value "option5"} "Option 5"]
> >  ]
> > ]
> >]
> >   )
> > 
> > But it reader this html code:
> > 
> >  > style="display: none;" data-reactid=".0.0.0">
> > Option 1
> > Option 2
> > 
> > Option 3
> > 
> > Option 5
> > 
> > 
> > 
> > The attribute multiple="" and selected="" , their values are not as 
> > expected.
> > 
> > Any ideas? 
> > 
> > Thanks in advance!

Thanks! this really help!

-- 
Note that posts from new members are moderated - please be patient with your 
first post.
--- 
You received this message because you are subscribed to the Google Groups 
"ClojureScript" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojurescript+unsubscr...@googlegroups.com.
To post to this group, send email to clojurescript@googlegroups.com.
Visit this group at http://groups.google.com/group/clojurescript.


[ClojureScript] Re: [Reagent, React] value of select/option's attribute is incorrect.

2015-03-30 Thread Francis Avila
Generally the React elements mirror dom objects rather than html tags and 
attributes.

For example, :multiple and :selected are booleans, not strings.


Also, the select element has a value property you can set directly instead of 
messing with :selected. 
https://facebook.github.io/react/docs/forms.html#why-select-value

Code should be more like:

(defn duallist [] 
  [:div.row 
   [:div.col-md-7 
[:select {:multiple true
  :value ["option2" "option3"]
  :size "10" 
  :name "duallistbox_demo" 
  :class "demo" 
  :style {:display "none"}} 
 [:option {:value "option1"} "Option 1"] 
 [:option {:value "option2"} "Option 2"] 
 [:option {:value "option3"} "Option 3"] 
 [:option {:value "option5"} "Option 5"] 
 ] 
] 
   ] 
  ) 


On Monday, March 30, 2015 at 5:32:54 AM UTC-5, Bin Li wrote:
> I created this reagent component:
> 
> (defn duallist []
>   [:div.row
>[:div.col-md-7
> [:select {:multiple "multiple"
>   :size "10" 
>   :name "duallistbox_demo"
>   :class "demo"
>   :style {:display "none"}}
>  [:option {:value "option1"} "Option 1"]
>  [:option {:value "option2" :selected "selected"} "Option 2"]
>  [:option {:value "option3" :selected "selected"} "Option 3"]
>  [:option {:value "option5"} "Option 5"]
>  ]
> ]
>]
>   )
> 
> But it reader this html code:
> 
>style="display: none;" data-reactid=".0.0.0">
>   Option 1
>   Option 2
>   
>   Option 3
>   
>   Option 5
> 
> 
> 
> The attribute multiple="" and selected="" , their values are not as expected.
> 
> Any ideas? 
> 
> Thanks in advance!

-- 
Note that posts from new members are moderated - please be patient with your 
first post.
--- 
You received this message because you are subscribed to the Google Groups 
"ClojureScript" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojurescript+unsubscr...@googlegroups.com.
To post to this group, send email to clojurescript@googlegroups.com.
Visit this group at http://groups.google.com/group/clojurescript.


[ClojureScript] Re: [Reagent, React] value of select/option's attribute is incorrect.

2015-03-30 Thread vvedee
As per spec they are correct 
http://www.w3.org/html/wg/drafts/html/master/infrastructure.html#boolean-attributes

"If the attribute is present, its value must either be the empty string or a 
value that is an ASCII case-insensitive match for the attribute's canonical 
name, with no leading or trailing whitespace."

On Monday, March 30, 2015 at 12:32:54 PM UTC+2, Bin Li wrote:
> I created this reagent component:
> 
> (defn duallist []
>   [:div.row
>[:div.col-md-7
> [:select {:multiple "multiple"
>   :size "10" 
>   :name "duallistbox_demo"
>   :class "demo"
>   :style {:display "none"}}
>  [:option {:value "option1"} "Option 1"]
>  [:option {:value "option2" :selected "selected"} "Option 2"]
>  [:option {:value "option3" :selected "selected"} "Option 3"]
>  [:option {:value "option5"} "Option 5"]
>  ]
> ]
>]
>   )
> 
> But it reader this html code:
> 
>style="display: none;" data-reactid=".0.0.0">
>   Option 1
>   Option 2
>   
>   Option 3
>   
>   Option 5
> 
> 
> 
> The attribute multiple="" and selected="" , their values are not as expected.
> 
> Any ideas? 
> 
> Thanks in advance!

-- 
Note that posts from new members are moderated - please be patient with your 
first post.
--- 
You received this message because you are subscribed to the Google Groups 
"ClojureScript" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojurescript+unsubscr...@googlegroups.com.
To post to this group, send email to clojurescript@googlegroups.com.
Visit this group at http://groups.google.com/group/clojurescript.