Skip to content

Checkbox won't render when using AJAX #27

@Maelstorm1973

Description

@Maelstorm1973

I've ran into an interesting problem. I have found that when rendering the page with AJAX (which is used everywhere today), checkboxes within the newly rendered content still show as a checkbox and not a switch. Rendering can be done by either DOM object manipulation or by direct HTML injection into a DIV tag. I have found that using this code

<!-- Checkbox Boot Script -->
<script type="text/javascript">
	function featureCheckbox() {
		$(':checkbox').checkboxpicker();
	}
</script>

at the bottom of the HTML template page, and then calling the function featureCheckbox() as the last action in the AJAX response handler, I was able to get it to work. The documentation should be updated to indicate this little caveat.

This is within the AJAX response handler.

// Feature Activations
if (typeof ajaxResponseHandler == typeof featureCheckbox)
{
	featureCheckbox();
}

Another thing that I noticed is that all checkboxes must be rendered and on screen before calling the activation routine. Any checkboxes that are rendered after the activation routine will not get the new visual and will remain as an ordinary checkbox. The documentation should be updated to reflect this.

Anyways, this is a nice addon. Good Job!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions