EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: galcott on August 04, 2022, 11:48:34 AM



Title: Width attribute of textbox doesn't work
Post by: galcott on August 04, 2022, 11:48:34 AM
It seems that setting the width attribute of a textbox doesn't work and it has to be done in a style tag.

This doesn't work - the width is ignored:
Code:
<INPUT class='easyui-textbox' ID='txtPatient' label='Patient' labelWidth=70 width=350>

This does work:
Code:
<INPUT class='easyui-textbox' ID='txtPatient' label='Patient' labelWidth=70 style='width: 350px'>

Am I missing something here or is this a bug?


Title: Re: Width attribute of textbox doesn't work
Post by: jarry on August 05, 2022, 12:06:39 AM
Please use the 'data-options' instead to define all the properties.
Code:
<INPUT class='easyui-textbox' ID='txtPatient' data-options="label:'Patient',labelWidth:70,width:350">

Or override the $.fn.textbox.parseOptions to parse the 'width' and 'height' properties.
Code:
<script>
(function($){
var parser = $.fn.textbox.parseOptions;
$.fn.textbox.parseOptions = function(target){
var extOpts = $.parser.parseOptions(target, ['width','height']);
return $.extend({}, extOpts, parser(target));
}
})(jQuery);
</script>


Title: Re: Width attribute of textbox doesn't work
Post by: galcott on August 05, 2022, 06:41:44 AM
I don't want to use data-options since I already have a page with over 100 textboxes defined as in the code I posted. Why do the other properties work and width doesn't? They should all behave consistently. This is a bug!


Title: Re: Width attribute of textbox doesn't work
Post by: galcott on August 08, 2022, 04:09:48 PM
Can you please respond to my last question about why this doesn't work? Thanks.


Title: Re: Width attribute of textbox doesn't work
Post by: jarry on August 09, 2022, 05:00:16 PM
This isn't a bug. The 'width' and 'height' are the element's inner styles, they aren't necessary to be redefined as a new attribute. If you really want to do that, you can override the $.fn.textbox.parseOptions function.
Code:
<script>
(function($){
var parser = $.fn.textbox.parseOptions;
$.fn.textbox.parseOptions = function(target){
var extOpts = $.parser.parseOptions(target, ['width','height']);
return $.extend({}, extOpts, parser(target));
}
})(jQuery);
</script>


Title: Re: Width attribute of textbox doesn't work
Post by: galcott on August 10, 2022, 01:49:24 PM
The issue is that every other property listed in the docs can be set using an attribute but these can't. So maybe not exactly a bug, but inconsistent behavior.