0

I've seen this question before but all the answers I saw do not apply to my particular problem. Most of the ones I've seen were caused by the click not being used in a document ready function. All of the stuff in setup_calenders and disable_items is happening but no alert pops up when the checkbox is clicked.

$(document).ready(setup)

function setup() {
$("id_Clearance").click(enable_clearance);
$("id_Paperwork").click(enable_paperwork);
$("id_AVSupport").click(enable_support);
setup_calendars();
disable_items();
}

function enable_paperwork()
{
alert("clicked");
}
4
  • Use .on() to avoid this kin of problem. Commented Aug 27, 2012 at 21:31
  • That won't help in this case. click() is a shortcut for .bind("click", handler), as well as for .on("click", handler) as of jQuery 1.7. api.jquery.com/click Commented Aug 27, 2012 at 21:32
  • for .on("click",handler), not for .on("click",selector,handler) Commented Aug 27, 2012 at 21:37
  • Right, and using delegated events like that helps a lot if you are updating/replacing the elements on the page. Commented Aug 27, 2012 at 21:42

3 Answers 3

6

You're missing the # signs that indicate that a selector should match an element ID:

$("#id_Clearance").click(enable_clearance);
$("#id_Paperwork").click(enable_paperwork);
$("#id_AVSupport").click(enable_support);
Sign up to request clarification or add additional context in comments.

1 Comment

I did there's was some kind of block setup that made me wait to accept :)
1

Is this what you want?

function setup() {
  $("#id_Clearance").click(enable_clearance);
  $("#id_Paperwork").click(enable_paperwork);
  $("#id_AVSupport").click(enable_support);
  setup_calendars();
  disable_items();
}

You need to include a # before an element's id to select for id. Just a name like that looks for a tag. eg:

<id_Clearance/>

jQuery has great documentation: http://api.jquery.com/category/selectors/

Comments

0

I could be wrong as I don't have your html source, but it looks like you might not have the correct selectors for IDs.

Currently, you're doing this:

$("id_Clearance").click(enable_clearance);
$("id_Paperwork").click(enable_paperwork);
$("id_AVSupport").click(enable_support);

If those are indeed supposed to be ids of elements on the page, you'll want to change it to this:

$("#id_Clearance").click(enable_clearance);
$("#id_Paperwork").click(enable_paperwork);
$("#id_AVSupport").click(enable_support);

Notice the # at the start of the selectors. That's what is used to select an id.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.