Looking for a way to italicize a series of summernote inputs by default? I have removed all toolbar options except the italics button. Here's the HTML generating these inputs:
<div style="width:250px;">
<div class="summernote" id="<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="247670617b6469">[email protected]</a>_ID">
@Html.HiddenFor(model => model.Answer, htmlAttributes: new { id = "Answer_" + @Model.ST_ID})
</div>
</div>
--
$(document).ready(function () {
$('.summernote').summernote({
toolbar: [
['style', ['italic']],
],
onChange: function (e) {
// Do some event
// Update the HiddenFor element with the formatted text
}
});
});
The italics button location is determined by CSS. Attempting to set all inputs to default to italics:
I tried:
$('.summernote').summernote('italic');
As per Summernote - Deep Dive
It only sets the first input, not the rest. Then I also tried:
$('.summernote').each(function() {
$(this).summernote('italic');
}
But it didn't work. Then, I attempted:
var elements = document.GetElementsByClassName('summernote');
for (i = 0; i < elements.length; i++) {
$(elements[i]).summernote('italic');
}
Unfortunately, no luck. Any ideas on how to achieve this?