Google Groups Home
Help | Sign in
Any way to avoid having this IE warning message?
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
  5 messages - Collapse all
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
laredotornado@zipmail.com  
View profile
 More options May 16, 3:56 pm
From: "laredotorn...@zipmail.com" <laredotorn...@zipmail.com>
Date: Fri, 16 May 2008 12:56:55 -0700 (PDT)
Local: Fri, May 16 2008 3:56 pm
Subject: Any way to avoid having this IE warning message?
Hi,

I have a page has a lot of data and can run slowly.  As soon as I try
and load this page, IE tells me

http://screencast.com/t/mXOBRKW1T2

(the script is causing this page to run slowly, continue?).  Anyway, I
notice when I take out this block of JQuery code, the message
disappears:

        $(document).ready(function() {
                $('.updateBtn').click(function(){
                        var rowId = $(this).parents("tr").attr("id");
                        saveRow(rowId);
                        alert("Item Updated");
                });

                $('tr.rowData :text, tr.rowData
textarea').blur(function() {
                        var id = $(this).parents("tr").attr("id");
                        saveRow(id);
                });
        });

Unfortunately, I need this code because I want to define these
behaviors on my page.  Is there a way to rewrite the above so that IE
doesn't complain?

Thanks, - Dave


    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 May 16, 5:09 pm
From: "Karl Rudd" <karl.r...@gmail.com>
Date: Sat, 17 May 2008 07:09:04 +1000
Local: Fri, May 16 2008 5:09 pm
Subject: Re: [jQuery] Any way to avoid having this IE warning message?
"Chunk" the code up using setTimeout().

http://groups.google.com/group/jquery-en/browse_thread/thread/aabbe7e...

Karl Rudd

On Sat, May 17, 2008 at 5:56 AM, laredotorn...@zipmail.com


    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.
laredotornado@zipmail.com  
View profile
 More options May 17, 1:45 pm
From: "laredotorn...@zipmail.com" <laredotorn...@zipmail.com>
Date: Sat, 17 May 2008 10:45:43 -0700 (PDT)
Local: Sat, May 17 2008 1:45 pm
Subject: Re: Any way to avoid having this IE warning message?
Hi,

Thanks for the link and your response, but I guess I'm slow.  I have
two event handlers (click and blur) that I want to definite within my
document.ready function.  How am I supposed to use setTimeout?  How do
I how long to set the timeout for if I don't know how long it will
take for the page to load?

Thanks ,- Dave

On May 16, 4:09 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.
Michael Geary  
View profile
 More options May 17, 3:30 pm
From: "Michael Geary" <M...@Geary.com>
Date: Sat, 17 May 2008 12:30:20 -0700
Local: Sat, May 17 2008 3:30 pm
Subject: RE: [jQuery] Re: Any way to avoid having this IE warning message?
The idea with setTimeout is not to wait until the page loads - you don't
have to guess at a specific timeout value - but to simply break up a long
script into pieces that don't have to all run at once. The typical
setTimeout interval for this purpose is 1 millisecond, i.e. the shortest
possible timeout.

IOW, if a script has to do a thousand things, have it do a hundred of them,
then a short timeout, then another hundred, another timeout, etc.

However, for what you're trying to do here, that doesn't sound like the
right way to fix it. I would use event delegation instead. Simply set a
*single* .click and .blur handler on the document body or on some element
that contains your table code, and inside the handlers, check to see if the
element that was clicked or blurred is one you're interested in.

A direct translation of your code would look something like this:

    $(function() {
        $('body')
            .click( function( event ) {
                var $target = $(event.target);
                if( $target.is('.updateBtn') ) {
                    varrowId = $target.parents('tr').attr('id');
                    saveRow(rowId);
                    alert('ItemUpdated');
                }
            })
            .blur( function( event ) {
                var $target = $(event.target);
                if( $target.is('tr.rowData:text, tr.rowData textarea') ) {
                    varid = $target.parents('tr').attr('id');
                    saveRow(id);
                }
            });
    });

(Well, a direct translation with a couple of liberties - I used the shorter
form of $(document).ready, and I compulsively changed the double quotes to
single quotes - which I recommend getting in the habit of doing, so when you
generate HTML code from your JS code, you can use double quotes in the HTML
without messy escaping.)

As you can see, the code sets a single handler each for .click and .blur on
the BODY element. (You could use any other element that contains your
table.) It uses event.target to get the element that was actually clicked or
blurred, and then .is() to test the element against your original selectors.
This will ignore clicks and blurs on other elements and process the ones for
the elements you're interested in.

I tried to understand the use of the varrowId, rowId, varid, and id
variables but couldn't make any sense of them. Are there some typos in
there, and missing "var" declarations? Or are those supposed to be global
variables?

Reading between the lines, I'm guessing that the actual intent of the code
may be more like this:

    $(function() {
        $('body')
            .click( function( event ) {
                var $target = $(event.target);
                if( $target.is('.updateBtn') ) {
                    save( $target );
                }
            })
            .blur( function( event ) {
                var $target = $(event.target);
                if( $target.is('tr.rowData:text, tr.rowData textarea') ) {
                    save( $target );
                }
            });

        function save( $target ) {
            saveRow( $target.parents('tr').attr('id') );
        }
    });

Does that look like what you want?

-Mike

textarea').blur(function() {


    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.
Ariel Flesler  
View profile
 More options May 19, 11:10 am
From: Ariel Flesler <afles...@gmail.com>
Date: Mon, 19 May 2008 08:10:39 -0700 (PDT)
Local: Mon, May 19 2008 11:10 am
Subject: Re: Any way to avoid having this IE warning message?

>if( $target.is('tr.rowData:text, tr.rowData textarea') )

$().is() doesn't support complex selectors (at least for now).

Cheers

--
Ariel Flesler
http://flesler.blogspot.com/

On 17 mayo, 16:30, "Michael Geary" <M...@Geary.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
©2008 Google