Grapesjs: Add and remove classes programmatically

Created on 18 Dec 2017  路  5Comments  路  Source: artf/grapesjs

I want to add and remove classes to a selected element, adding classes is working well, but removing them is not

var componentModel = editor.getSelected();
componentModel.addClass('form-color');

I want to be able to do

componentModel.removeClass('form-color');

But its throwing an error.

I'd be grateful if someone could share the correct syntax

outdated

Most helpful comment

I'll add removeClass in the next release

All 5 comments

Looking at
https://github.com/artf/grapesjs/blob/dev/src/dom_components/model/Component.js#L276

I would say removeClass is not implemented.
If you know the other classes I think you can do setClass with an array that don't have the class you want to remove

That worked great, thanks for your help :)

I'll add removeClass in the next release

I think that would be cool 馃憤

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kickbk picture kickbk  路  3Comments

desilvaNSP picture desilvaNSP  路  3Comments

alibouaziz picture alibouaziz  路  3Comments

kawika-connell picture kawika-connell  路  3Comments

FlashPapa picture FlashPapa  路  3Comments