event and .trigger()

event and .trigger()

Hi Folks,

I'm jiggling around with some curiosity (which maybe isn't really one).

In a click event handler for a CHECKBOX I have this code (example):

  1. if($(this).attr('checked')) {do something}
if you click on that checkbox (by yourself, with your own hand and your own mouse), the handler is fired and its attribute checked is = checked.

===-- setting back the checkbox state to unchecked (pagereload) --===

Now, if you call $("#that-checkbox").trigger("click") from somewhere else, $(this).attr('checked') is no longer = checked within the event handler.
That means some trouble to me, because I want to set some saved settings automatically.

Is that behaviour supposed to be ? any ideas?

The "behavior" is, that the checkbox state is updated before the click event is over, if you click on it manually.

Kind Regards