[CLOSED] Element got style="width:0px;" default

Page 1 of 2 12 LastLast
  1. #1

    [CLOSED] Element got style="width:0px;" default

    Hi,

    My situation is pretty strange default style attribute with value width:0px; is loaded even though I doesn't do anything like this for my own.
    It's for sure problem with my app because I've tryed wrote simplest sample and this behaviour doesn't occure ;/

    In this case I've tryed wrote some other way to make it right(ExtJs script in my guess)

    I've wrote this script which should replace old value 0px with new one 60% ( required of scalability).
    <script type="text/javascript">
            Ext.onReady(function () {
                var items = Ext.select('div.x-form-element');
                var items2 =Ext.select('div.x-form-element:first-child');
                for (var item in items) {
                    item.setStyle('width', '60%');
                }
                for(var item2 in items2)
                {
                    item2.setStyle('width', '60%');
                }
            });
        </script>
    but in firebug console I've got error says
    TypeError: item.setStyle is not a function
    even when in ExtJs 3.4 documentation it's exists.
    What am I doing wrong?

    Thanks,
    ViDom
    Last edited by Daniil; Feb 07, 2013 at 3:43 AM. Reason: [CLOSED]
  2. #2
    Hi @ViDom,

    Hard to say why width is 0 in your application.

    Could you provide a full sample to reproduce the issue with the provided code snippet?
  3. #3
    Like i wrote in starting post:
    It's for sure problem with my app because I've tryed wrote simplest sample and this behaviour doesn't occure ;/
    I've got really nested architecture about 5-6 levels of nesting so it's almost impossible to make simple sample for this.
    so answer to your question @Daniil is no I can't make such kind of sample:(

    I need to change this with javascript(solution for now).
  4. #4
    Well, maybe, Ext.onReady is too early to work with the DOM objects of the components. We might be not rendered yet.

    I would suggest to listen to the AfterRender event of some container where you place the fields.

    Also, please try:
    Ext.select('div.x-form-element').setStyle('width', '60%');
    Ext.select('div.x-form-element:first-child').setStyle('width', '60%');
    instead of your JavaScript code.
    Last edited by Daniil; Feb 01, 2013 at 3:45 AM.
  5. #5
    Quote Originally Posted by Daniil View Post
    Well, maybe, Ext.onReady is too early to work with the DOM objects of the components. We might be not rendered yet.

    I would suggest to listen to the AfterRender event of some container where you place the fields.

    Also, please try:
    Ext.select('div.x-form-element').setStyle('width', '60%');Ext.select('div.x-form-element:first-child').setStyle('width', '60%');
    instead of your JavaScript code.
    Ok I've just tryed your code:)
    it's changed only elements with .x-form-element class not first child in it it's can be mistake in my sample.
    Do I get child in proper selector?
  6. #6
    Please clarify what exactly elements are you trying to fetch?
  7. #7
    Quote Originally Posted by Daniil View Post
    Please clarify what exactly elements are you trying to fetch?
    <div id="ext-comp-1002" class=" x-form-composite x-box-layout-ct x-form-field" style="width: 0px;">
    this is html of what I need get it's first child of div with x-form-element class
  8. #8
    Quote Originally Posted by ViDom View Post
    it's changed only elements with .x-form-element class not first child in it it's can be mistake in my sample.
    Well, if you want to apply the width for the first child only, then, I think, you should remove:
    Ext.select('div.x-form-element').setStyle('width', '60%');
    Quote Originally Posted by ViDom View Post
    <div id="ext-comp-1002" class="  x-form-composite x-box-layout-ct x-form-field" style="width:  0px;">
    this is html of what I need get it's first child of div with x-form-element class
    Yes, the selector looks correct.
  9. #9
    Quote Originally Posted by Daniil View Post
    Well, if you want to apply the width for the first child only, then, I think, you should remove:
    Ext.select('div.x-form-element').setStyle('width', '60%');


    Yes, the selector looks correct.
    I want to apply with to x-form-element and to first child of it which I showed in previous post.
    First child hasn't be processed. With my code
    Ext.select('div.x-form-element:first-child').setStyle('width', '60%');
  10. #10
    Maybe, you need this.
    Ext.select('div.x-form-element input:first-child')
    Honestly, the requirement is a bit unclear. Maybe, providing us with a mockup of your page where you would highlight and describe main points could clarify something. I mean that, maybe, there is some better solution.
Page 1 of 2 12 LastLast

Similar Threads

  1. Replies: 1
    Last Post: Jun 26, 2012, 11:29 AM
  2. Replies: 5
    Last Post: May 02, 2012, 5:37 PM
  3. Replies: 4
    Last Post: Oct 11, 2011, 2:42 AM
  4. Replies: 2
    Last Post: Jun 26, 2011, 1:59 AM
  5. Replies: 1
    Last Post: Apr 25, 2011, 4:07 AM

Tags for this Thread

Posting Permissions