EasyUI Forum
March 29, 2024, 05:06:37 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Width attribute of textbox doesn't work  (Read 1942 times)
galcott
Newbie
*
Posts: 39


View Profile
« 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?
Logged
jarry
Administrator
Hero Member
*****
Posts: 2260


View Profile Email
« Reply #1 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>
Logged
galcott
Newbie
*
Posts: 39


View Profile
« Reply #2 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!
Logged
galcott
Newbie
*
Posts: 39


View Profile
« Reply #3 on: August 08, 2022, 04:09:48 PM »

Can you please respond to my last question about why this doesn't work? Thanks.
Logged
jarry
Administrator
Hero Member
*****
Posts: 2260


View Profile Email
« Reply #4 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>
Logged
galcott
Newbie
*
Posts: 39


View Profile
« Reply #5 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.
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!