Issue #842πŸ’¬ AnsweredOpened February 6, 2018by Deepak8130 reactions

How we can set array using editor.getSelected().set('attributes',array value)

Quick answerby arthuralmeidap

@Deepak813 , You should follow one of the following syntaxes:editor.getSelected().set({title: "March 20", content: "In his eyes she eclipses..."}); -> for multiple attributes. You send a objecteditor.getSelected().set("title", "March 20"); -> for a specific attribute

Read full answer below ↓

Question

Hi @artf,

How we can set array values using editor.getSelected().set('attributes',array value); If we try to do so with the same code then it insert NaN to attributes.

Answers (3)

arthuralmeidapβ€’ February 6, 2018

@Deepak813 ,

You should follow one of the following syntaxes:

  • editor.getSelected().set({title: "March 20", content: "In his eyes she eclipses..."}); -> for multiple attributes. You send a object

  • editor.getSelected().set("title", "March 20"); -> for a specific attribute

artfβ€’ February 7, 2018

How we can set array values using editor.getSelected().set('attributes',array value);

You can't set array on attributes property, it should be an object instead.

I'd recommend using a more specific methods like model.setAttributes({ title: '' }) or addAttributes({ ... })

lock[bot]β€’ September 18, 2019

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.

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...

Free option

Check the open-source GrapesJS plugins on GitHub or run a quick search in our free catalog.

Browse free plugins β†’
Premium option

Premium plugins ship with support, regular updates, and production-ready features β€” save days of integration work.

Browse premium plugins β†’

Related tutorials

In-depth guides on the same topic.

All tutorials β†’

Browse Plugin Categories

Jump directly to plugin category pages on the marketplace.