On Sep 21, 7:09 am, "T.J. Crowder" <t...@crowdersoftware.com> wrote:
> Hi,
>
> > Hi Crowder,
>
> LOL -- so no one else on the list is allowed to answer? ;-)
>

LOL! LOL! I have been following the group for around a year though
this is my first email. I generally read most of your replies as those
are very well explained.  (Did I boosted up someone's ego ??  :) )  I
really did not want to get any reply on the work-around as I thought
of few work arounds already.  I knew I was missing something but was
not sure how to extend an array element (since Safari and FF working
fine, I was thinking that it was IE glitch). Thanks for all your three
solutions.  I knew that the $$('td') will not work as it returns an
array but I was so exhausted by that time and not sure how to get an
element from the array which will work with getWidth().

Thanks again.  Appreciate your prompt reply.
Somdatta Nath

> > var tdElem = this.containerElement.getElementsByTagName("td");
> > var colItem = tdElem.item(0);
> > var colWidth = colItem.style.width;
> > var colWidth = (col.item(0)).getWidth(); // not working in IE.  It is dying.
>
> That's because on IE, Prototype can't automagically extend elements.
> You have to explicitly extend them by passing them through `$`, or
> retrieve them via Prototype (which will extend them for you before
> giving them to you). In the code above, you've used raw DOM methods to
> get the NodeList and get the Element from it, so it doesn't have
> Prototype's syntactic sugar. More here:http://prototypejs.org/learn/extensions
>
> Or to put all that another way, try this:
>
> var tdElem = this.containerElement.select("td");
> //Or var tdElem = $(this.containerElement).select("td"); if
> this.containerElement hasn't
> //already been extended
> var colItem = tdElem[0];
> var colWidth = colItem.getWidth();
>
> or this:
>
> var tdElem = this.containerElement.getElementsByTagName("td");
> var colItem = tdElem.item(0);
> var colWidth = $(col.item(0)).getWidth();
>             // ^-- change is here
>
> > var colWidth = $$('td').getWidth();  // Not working if the table is created
> > dynamically
>
> That won't work regardless of whether the table was created
> dynamically or not. `$$` returns an Array, not an Element, and arrays
> don't have a `getWidth` function. You'd need something like this (for
> the first one):
> var colwidth = $$('td')[0].getWidth();
>
> HTH,
> --
> T.J. Crowder
> Independent Software Engineer
> tj / crowder software / com
> www / crowder software / com
>
> On Sep 21, 2:41 pm, Somdatta Nath <nath.somda...@gmail.com> wrote:
>
>
>
> > Hi Crowder,
>
> > I am having some problem in implementing a dynamic table and getting the
> > width of an td element in IE (Safari, FF works ok.)
> > I am creating the table as :
>
> > var myTable = document.createElement("table");
>
> > var myThead = document.createElement("thead");
> > var myTfoot = document.createElement("tfoot");
>
> > var myTbody = document.createElement("tbody");
>
> > var myRow = document.createElement("tr");
>
> > var myCell = document.createElement("td");
>
> > myTable.appendChild(myThead);
> > myTable.appendChild(myTfoot);
>
> > myTable.appendChild(myTbody);
>
> > myTbody.appendChild(myRow);
>
> > myRow.appendChild(myCell);
>
> > this.containerElement.appendChild(myTable);
>
> > -------------------------------
>
> > I have a css file where I set up the style for the td element.
>
> > td.one
> > {
> > height:80px;
> > width:80px;
> >  border: 1px solid #000;
> >  background:#333;
>
> > vertical-align:middle;
> > voice-family: "\"}\"";
> > voice-family: inherit;
> > width: 78px; }
>
> > td { width:78px; } ,
>
> > ----------------------
>
> > After running the the code, I could see that the table with one cell is
> > getting created correctly.  But if I try to get width, I am not getting
> > anything.
>
> > However, if I create the table in a static html code.  At least I can query
> > the element by :
>
> > var tdElem = this.containerElement.getElementsByTagName("td");
>
> > var colItem = tdElem.item(0);
>
> > var colWidth = colItem.style.width;
>
> > var colWidth = (col.item(0)).getWidth(); // not working in IE.  It is dying.
>
> > var colWidth = $$('td').getWidth();  // Not working if the table is created
> > dynamically
>
> > ------------------------
>
> > This probably already an discussed topic.  I am wondering why is this
> > difference between statically and dynamically created table ?  Is there a
> > way to get width of the td element (created dynamically) that works in IE?
> >  I do not have any problem in getting getWidth() working for dynamically
> > created table in FF and Safari.
>
> > Any help is appreciated.
>
> > Thanks so much,- Hide quoted text -
>
> - Show quoted text -

-- 
You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to prototype-scriptacul...@googlegroups.com.
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en.

Reply via email to