I asked a similar question over in Development, but it looks like this might be the more appropriate place since I’m really actually requesting some support
I have the following HTML panel code:
<html lang="en">
<head>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.100.2/css/materialize.min.css">
<style>
.input-field.col .dropdown-content [type="checkbox"]+label {
top: -10px;
}
.caret {
border-color: transparent !important;
}
</style>
</head>
<body>
<div class="container">
<div class="row">
<div class='input-field col s6'>
<select class='multiselect' multiple>
<option value="" disabled selected>Datacenter</option>
<option value="rs-iad">rs-iad</option>
<option value="rs-lhr">rs-lhr</option>
<option value="rs-ord">rs-ord</option>
<option value="unknown">unknown</option>
</select>
</div>
</div>
</div>
<!-- Latest compiled JavaScript -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.100.2/js/materialize.min.js"></script>
<script type="text/javascript">
$('.multiselect').material_select();
</script>
</body>
</html>
When I navigate to this scripted dashboard, I get exceptions at first:
TypeError: $(…).material_select is not a function
But if I click Edit and go to the HTML content, modify a single character, everything magically renders just fine. How can I get around this? I’m not super great at web development in general, so if I’m doing something completely wrong in my HTML content, apologies.
I’ve tried wrapping the material_select()
in a $(document).ready()
, but this produces the same result.
For ease of reproducing, here’s my entire paneled JSON:
"content": "<!DOCTYPE html>\n<html lang=\"en\">\n <head>\n <!-- Latest compiled and minified CSS -->\n <link rel=\"stylesheet\" href=\"https://cdnjs.cloudflare.com/ajax/libs/materialize/0.100.2/css/materialize.min.css\">\n <style>\n .input-field.col .dropdown-content [type=\"checkbox\"]+label {\n top: -10px;\n }\n .caret {\n border-color: transparent !important;\n }\n </style>\n </head>\n <body>\n <div class=\"container\">\n <div class=\"row\">\n <div class='input-field col s6'>\n <select class='multiselect' multiple>\n <option value=\"\" disabled selected>Datacenter</option>\n <option value=\"bio-dub\">bio-dub</option>\n <option value=\"ea-ams\">ea-ams</option>\n <option value=\"ea-iad\">ea-iad</option>\n <option value=\"rs-iad\">rs-iad</option>\n <option value=\"rs-lhr\">rs-lhr</option>\n <option value=\"rs-ord\">rs-ord</option>\n <option value=\"unknown\">unknown</option>\n </select>\n </div>\n </div>\n </div>\n \n <!-- Latest compiled JavaScript -->\n <script src=\"https://cdnjs.cloudflare.com/ajax/libs/materialize/0.100.2/js/materialize.min.js\"></script>\n <script type=\"text/javascript\">\n $('.multiselect').material_select();\n </script>\n </body>\n</html>",
"id": 1,
"mode": "html",
"span": 12,
"title": "Panel Title",
"type": "text",
"links": []
}
Should note that I’ve tested regular scripted and async - both produce the same issue.