replace html issue
Question
I defined new forum block like this.
blockManager.add('block-forum', {
label: 'Blog, Discussion or Forum',
attributes: {class: 'fa fa-list-alt'},
content: `
<DIV class='forum_directory'>
<div class="resource" data-gjs-editable="false" data-gjs-selectable="false" data-gjs-hoverable="false" data-gjs-propagate='["editable", "selectable", "hoverable"]'>
Select an item in the configuration panel on the right.
</div>
</DIV>`,
category: 'Other',
});
I want to replace resource class with ajax response html. Currently I did it like this.
var replaceResource = function(model, data) {
if (model) {
var element = model.view.$el;
var object = element.find('.resource')[0];
object.innerHtml = data;
}
};
The problem is Hover is not working after this replacing. The data contains several div tags. I want to make hover action working correctly for the forum_directory class.
Answers (3)
You should change the model of the component, not its view
if (model) {
const resourceModel = model.find('.resource')[0];
resourceModel.components(data);
}
Thanks. It's working fine. But I want to add attribute something like data-gjs-selectable: false, data-gjs-editable:false to this resourceModel
You can resourceModel.set({ selectable: false, editable: false })
Related Questions and Answers
Continue research with similar issue discussions.
Issue #1817
Change HTML content while block is render in editor
Hello @artf I have one block into block manager like As per above script inside the block, i want to add dynamic HTML content while this bl...
Issue #1584
Not getting the Script of Block from editor.getComponents()
Below is the Component that I'm adding. this.editor.BlockManager.add('dob-mmyy-pii', { id: 'dob-mmyy', label: DOB (MM, YYYY) (PII), categor...
Issue #1471
[Question] Blockmanager and Image
Hi! I use this code to add a new block: blockManager.add("image", { label: 'Image', category: 'Basic', attributes: { class: "gjs-fonts gjs-...
Issue #1034
insert element or block inside parent element
Good day, i have component, have block i have Trait on listen changes, how can I add "h1 " inside that block "'<div class="container" style...
Paid Plugins That Match This Issue
Curated by issue keywords and label relevance to help you ship faster.
Loading paid plugin recommendations...
Browse Plugin Categories
Jump directly to plugin category pages on the marketplace.