Issue #1624Opened November 30, 2018by crypto-dump0 reactions

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)

artfDecember 1, 20180 reactions

You should change the model of the component, not its view

if (model) {
	const resourceModel = model.find('.resource')[0];
	resourceModel.components(data);
}
crypto-dumpDecember 4, 20180 reactions

Thanks. It's working fine. But I want to add attribute something like data-gjs-selectable: false, data-gjs-editable:false to this resourceModel

artfDecember 7, 20180 reactions

You can resourceModel.set({ selectable: false, editable: false })

Related Questions and Answers

Continue research with similar issue discussions.

Paid Plugins That Match This Issue

Curated by issue keywords and label relevance to help you ship faster.

View all plugins

Loading paid plugin recommendations...

Browse Plugin Categories

Jump directly to plugin category pages on the marketplace.