tags:

views:

29

answers:

3
$(document).ready(function() {
     $("#FieldsetID").each(function() {
                 $('.Isubmit').attr('disabled', 'disabled');
            });
});

the button showing as disabled but when I click on that its doign action?

is that something i am doing wrong?

thanks

+2  A: 

I don't think you can run an .each() function on a unique element. It's unique because you are using an #id selector.

You just need to do this:

$(document).ready(function() {
     $('#FieldsetID .Isubmit').attr('disabled', 'disabled');
});

Now the buttons shouldn't be clickable.

ryanulit
He says the button is already showing as disabled, so I don't think that's the problem. Also, while you shouldn't run each on an id selector, nothing says you can't, so his code should still work despite being inefficient.
Mark
@Mark - +1 Nothing (except for best practices) to prevent a person from looping over an array of one item.
patrick dw
+1  A: 

Altough untested, i think when you are selecting elements by id, you don't need to use each as it returns one element, and when you are selecting using class you have to use each, try using each on disabling selector and see.

Teja Kantamneni
+1  A: 

For some reason, IE doesn't prevent the event from bubbling when you click a disabled submit button.

I assume you have some other event handler on an ancestor that is therefore being triggered.

In that ancestor's event handler, it looks like you'll need to test to see if the submit button was clicked and if it is disabled. If so, you'll return false; to prevent the code from running, or the submit from occurring, or whatever.

       // Not sure if this is the right event, but you get the idea
$( someSelector ).click(function( event ) {
    var $target  = $(event.target);
                  // check to see if the submit was clicked
                  //    and if it is disabled, and if so,
                  //    return false
    if( $target.is(':submit:disabled') ) {
        return false;
    }
});
patrick dw