I am developing some components based on React.js for render jQuery Mobile objets.
I created the 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 I called it as below:
render: function() {
return React.DOM.div(null,
JQueryMobileForm(null,
JQueryMobileInputText({name:'texto1', label:'Texto', hideLabel:true})
),
);
}
I expected the follow HTML as 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 I get something different than 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 the label's "for" property was not added?
- Why my div's class does not have the ui-hide-label string?
- Why a new div was added for the input?