1

We have a pop-up dialog with multiple checkboxes that are each created using the following code segment:

   var cb = jQuery("<input></input>", { id: "cb_" + lid, name: "cb_" + lid, type: "checkbox" }).addClass("targetLayers_cb"); // CSS class used to facilitate validation only
   cb.prop("checked", li.searchable);

The boolean li.searchable field is used to determine whether the checkbox is checked or not on creation. The appearance of the checkboxes is not changing after the first invocation even if the li.searchable field changes.

I expect them to show based on the latest field value.

1 Answer 1

1

jQuery is not a reactive framework. The line cb.prop("checked", li.searchable) just sets the value of the checked property to the value that li.searchable has at the time. When the value of li.searchable changes, you'll need to call cb.prop("checked", li.searchable) again.

Or use a reactive framework, such as React, Vue, etc.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.