EasyUI Forum

General Category => General Discussion => Topic started by: cdtuql on April 24, 2017, 10:33:52 PM



Title: in $(function(){ }) can't init easyui_form input ?
Post by: cdtuql on April 24, 2017, 10:33:52 PM
I need to set value for the textbox input  when the page open,but it don't work ,how can i do?

 <tr>
      <td><s:message code="exchangeshift.page.currentshiftno" /></td>
      <td><input class="easyui-textbox" type="text" name="currentshiftno"    style="width:122px"/></td>
      <td><s:message code="exchangeshift.page.currentshiftno" /></td>
      <td><input id="bussiness_exchangeshift_bc"  style="width:80px"  name="shiftno" class="easyui-combobox" data-options="valueField:'shiftno',textField:'



$(function(){  
       alert(1);
        $.ajax({
            type:'POST',
            url:'${pageContext.request.contextPath}/exchangeshift/getCurrentExchangeShiftRec',
            success:function(data){
               console.log(data);
               $('#bussiness_exchangeshift_form').form('load',data);
               alert(data.bc.shiftno);
               $('#bussiness_exchangeshift_form  input[name=currentshiftno]').setValue(data.bc.shiftno);
               $('#bussiness_exchangeshift_form  input[name=currentbcseqno]').attr("value",data.shiftexchangeSeq);
               $('#bussiness_exchangeshift_form  input[name=fshiftExchangeReco_req]').attr("value",data.fshiftExchangeReco_seq);

               $('#business_exchangeshift_gunlog_grid').datagrid('load',data.gunexchangeshiftlogs);
               
            },

$('#bussiness_exchangeshift_form  input[name=currentshiftno]').setValue(data.bc.shiftno);
this did not work
But if I delete the class="easyui-textbox"  It worked?
can any one help me


Title: Re: in $(function(){ }) can't init easyui_form input ?
Post by: stworthy on April 25, 2017, 11:56:37 PM
You should call the 'setValue' method of textbox to modify the component's value.
Code:
<input id="currentshiftno" class="easyui-textbox" type="text" name="currentshiftno"    style="width:122px"/>
<script>
...
$('#currentshiftno').textbox('setValue',data.bc.shiftno);
</script>