Google Groups Home
Help | Sign in
$('<a>').size() === 0 in IE??
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  3 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Peter Bengtsson  
View profile  
 More options Apr 2 2008, 12:47 pm
From: Peter Bengtsson <pete...@gmail.com>
Date: Wed, 2 Apr 2008 09:47:58 -0700 (PDT)
Local: Wed, Apr 2 2008 12:47 pm
Subject: $('<a>').size() === 0 in IE??
I'm going to explain my problem by code. Both of these work perfectly
fine in Firefox but only the *second one* works in IE 6.

** THE ONE I WANTED TO WRITE **

function __duplicateToolbarButtons() {
   // Make "save" and "save and view" buttons appear in toolbar
   if ($('#CMSButtonBar').size() && $
('input.duplicateintoolbar').size()) {
      // Next, make <A> elements then put them into button bar
      $('input.duplicateintoolbar').each(function() {
         var btn = this;
         var a = $("<a>")
           .attr('href','#')
             .addClass('ButtonAction')
               .click(function() {
                  btn.click(); return false
               })
                 .text(btn.value);

         // insert it just before the last <div> in that area
         $('div', $('#CMSButtonBar')).slice(-1).before(a);

      });
   }

}

** THE ONE I HAD TO WRITE **

function __duplicateToolbarButtons() {
   // Make "save" and "save and view" buttons appear in toolbar
   if ($('#CMSButtonBar').size() && $
('input.duplicateintoolbar').size()) {
      // Next, make <A> elements that put them into button bar
      $('input.duplicateintoolbar').each(function() {
         var btn = this;

         var a = document.createElement('a');
         a.setAttribute('href','#');
         a.className='ButtonAction'; //
a.setAttribute('class','ButtonAction') doesn't work
         a.onclick=function() {btn.click(); return false};
         a.innerHTML=btn.value;

         // insert it just before the last <div> in that area
         $('div', $('#CMSButtonBar')).slice(-1).before(a);

      });
   }

}

At first I thought it was something wrong with the way I appended the
created element into the DOM tree but then I added this code just
after the $('<a>')... stuff::

 alert(a.size());

In Firefox it said 1 (as expected) but in IE 6 it said 0!! Why?
Are there pitfalls I don't know about in creating elements in IE that
are FAQ?

PS. This is jquery-1.2.3.min.js and the piece of junk is IE 6.0 sp2.


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Karl Rudd  
View profile  
 More options Apr 2 2008, 5:01 pm
From: "Karl Rudd" <karl.r...@gmail.com>
Date: Thu, 3 Apr 2008 08:01:02 +1100
Local: Wed, Apr 2 2008 5:01 pm
Subject: Re: [jQuery] $('<a>').size() === 0 in IE??
Try making a full formed "a" element, $('<a></a>'). IE is a bit fussy
sometimes about what it will create, it will fail when you specify an
"open" element.

Karl Rudd


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Peter Bengtsson  
View profile  
 More options Apr 3 2008, 5:46 am
From: Peter Bengtsson <pete...@gmail.com>
Date: Thu, 3 Apr 2008 02:46:09 -0700 (PDT)
Local: Thurs, Apr 3 2008 5:46 am
Subject: Re: $('<a>').size() === 0 in IE??
Thanks! That made it work. In the same javascript I managed to create
a div tag in IE with
$("<div>") but maybe there's some other subtlety behind that.

On Apr 2, 10:01 pm, "Karl Rudd" <karl.r...@gmail.com> wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google