javascript - React and jQuery Mobile Render Issues -
i developing components based on react.js render jquery mobile objets.
i created follow class:
var jquerymobileinputtext = react.createclass({ displayname: 'jquerymobileinputtext', getdefaultprops: function() { return {'name':'n'+uniqid(), 'label':'', 'type':'text', value:'', 'hidelabel':false } }, render: function() { var label = react.createfactory('label'); var input = react.createfactory('input'); var classstr = this.props.class; if (this.props.hidelabel) { classstr += (classstr == "" ? '' : ' ') + 'ui-hide-label'; } return ( react.dom.div({'data-role':'fieldcontain', 'class':classstr}, label({'for':this.props.name}, this.props.label), input({'type':this.props.type, name:this.props.name, id:this.props.name, value:this.props.value, placeholder:this.props.label} ) )); } }); jquerymobileinputtext = react.createfactory(jquerymobileinputtext); and called below:
render: function() { return react.dom.div(null, jquerymobileform(null, jquerymobileinputtext({name:'texto1', label:'texto', hidelabel:true}) ), ); } i expected follow html result:
<div data-role="fieldcontain" class="ui-hide-label"> <label for="texto1">texto</label> <input type="text" name="texto1" id="texto1" value="" placeholder="texto"/> </div> but different this:
<div data-role="fieldcontain" data-reactid=".0.0.1.0.5.0" class="ui-field-contain"> <label data-reactid=".0.0.1.0.5.0.0">texto</label> <div class="ui-input-text ui-body-inherit ui-corner-all ui-shadow-inset"> <input type="text" name="texto1" id="texto1" value="" placeholder="texto" data-reactid=".0.0.1.0.5.0.1"> </div> </div> my questions are:
- why label's "for" property not added?
- why div's class not have ui-hide-label string?
- why new div added input?
for number 1, per answer https://stackoverflow.com/a/22752418/930517, need use htmlfor instead of for.
on number 2, work if exchange react.dom.div({'data-role':'fieldcontain', 'class':classstr}, react.dom.div({'data-role':'fieldcontain', 'classname':classstr},?
finally, suggest there other code on page manipulating class names , adding div around input neither of these mentioned in code posted above.
are using other libraries other react? can test component outside app (e.g. in jsfiddle)?
Comments
Post a Comment