Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Checkbox won't render when using AJAX #27

Open
Maelstorm1973 opened this issue Dec 26, 2016 · 0 comments
Open

Checkbox won't render when using AJAX #27

Maelstorm1973 opened this issue Dec 26, 2016 · 0 comments

Comments

@Maelstorm1973
Copy link

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant