EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: yamilbracho on November 01, 2014, 10:34:33 AM



Title: Init a DateBox
Post by: yamilbracho on November 01, 2014, 10:34:33 AM
I am trying to read to a datebox
My datebox is defined as :

<input class="easyui-datebox"
      name="fe_nacimiento"
      required="true"
      data-options="formatter:myformatter, parser:myparser">

and the code to get from database

var urlData = './get_data.php';
$.get(urlData, function(response) {
   var response = eval('(' + response + ')');
            
   alert(response.fe_nacimiento);
   $("[name='fe_nacimiento']").datebox('setValue', response.fe_nacimiento);
})

The alert shows "2015-12-31", and the javascript console

Uncaught TypeError: Cannot read property 'options' of undefined

And the datebox is in blank. There are another fields that i bring from the database and
they are show in their text and combo boxes...

Any hint...

TIA
Yamil


Title: Re: Init a DateBox
Post by: yamilbracho on November 01, 2014, 01:20:48 PM
Wow, I solved it!!!!
Just add an id to my datebox, say

<input class="easyui-datebox"
       id="fe_nacimiento"
   name="fe_nacimiento"
   required="true"
   data-options="formatter:myformatter, parser:myparser">

And change :
    $("[name='fe_nacimiento']").datebox('setValue', response.fe_nacimiento);
to
$('#fe_nacimiento').datebox('setValue', fechaNac);

It looks like JEasyUI works better if your add an id to your inputs...

Regards,
Yamil