Thanks for the suggestions, although I must say that I find the first version of the code easier to understand

Do you have an answer for my last question too?

Paul_Wilkins
—
2011-03-24T23:44:35Z —
#12

D3V4 said:

A question that came up to my mind right now: is there an event that I can use to see if a checkbox is checked or unchecked by another javascript file and not by a user?

The elements' click event will trigger no matter where the change is coming from.

D3V4
—
2011-03-25T06:26:07Z —
#13

I must have a problem with my scripts though. I have a script that checks or unchecks all the checkboxes (after clicking on a link) and another script that shows the correspondent column if the checkbox is checked, or hides it otherwise.

If I uncheck a checbox manually, the column is hidden. If I make the script check all the checkboxes (clicking on the link), all the checkboxes become checked but the one I had unchecked previously remains hidden, even if it's now checked.

I don't know if I've made my point clear here thanks for all your help, by the way

Paul_Wilkins
—
2011-03-25T06:33:01Z —
#14

D3V4 said:

I must have a problem with my scripts though.

Perhaps not, and perhaps I wasn't being clear enough in my response.

What I was meaning to say is that it doesn't matter where the click event comes from. A person can click on the checkbox, or a script can trigger the click event on the checkbox. Whether by user or scripted command, it is the same event that is run.

D3V4 said:

I have a script that checks or unchecks all the checkboxes (after clicking on a link) and another script that shows the correspondent column if the checkbox is checked, or hides it otherwise.

If you are directly editing the checked property of the checkbox, then that won't trigger the click event. Instead of directly editing that value, first investigate to find out if it is checked or not. If it's not in the correct state, trigger the click event on that checkbox and that should get you closer to a solution.

D3V4
—
2011-03-27T12:29:28Z —
#15

paul_wilkins said:

If you are directly editing the checked property of the checkbox, then that won't trigger the click event. Instead of directly editing that value, first investigate to find out if it is checked or not. If it's not in the correct state, trigger the click event on that checkbox and that should get you closer to a solution.

Ok, now I'm not editing the property value but I'm using trigger to launch the click event, but it still isn't working.

I mean, the checkbox becomes checked but the script that should run after a click event is not executed.

Paul_Wilkins
—
2011-03-27T14:56:15Z —
#18

D3V4 said:

Ok, now I'm not editing the property value

I have difficulty interpreting what that means in terms of the code. Can you show it, along with how you're using the trigger event to fire off a command to run on page load the event that updates the counter?

D3V4
—
2011-03-27T15:13:28Z —
#19

paul_wilkins said:

I have difficulty interpreting what that means in terms of the code. Can you show it, along with how you're using the trigger event to fire off a command to run on page load the event that updates the counter?

for which you also suggested some improvements which I still have to implement

.trigger() correctly triggers the click event on the checkboxes, but the code inside the third box is not executed.

Let me know if you need further explanations.

Paul_Wilkins
—
2011-03-27T15:23:05Z —
#20

D3V4 said:

.trigger() correctly triggers the click event on the checkboxes, but the code inside the third box is not executed.

Let me know if you need further explanations.

I have an inkling of a suspicion that one of the possible causes might be that the trigger is occurring before the click event has a chance to exist, but I'm also puzzled about just what this third box is that you refer to?

It would help if you could linked to a test page where the problem can be experienced, and the code can be examined with greater thoroughness.