Issue #1385💬 AnsweredOpened August 27, 2018by ionic6660 reactions

About the use of setAttributes

快速解答by arthuralmeidap

so, in the second case do you want to update the same data-info attribute with a new key, right? since data-info has a string as a type value, first you need to get it and parse to an object. const dataInfoObject = JSON.parse(this.model.get('data-info')) after that, you can update the object with the new key dataInfoO...

Read full answer below ↓

Question

hi,I saved an object in the custom property。 2018-08-27_145924 And I want to implement putting values into custom properties。 2018-08-27_150059 but It will cover the previous one 2018-08-27_150154 2018-08-27_150211

Answers (3)

arthuralmeidapAugust 30, 2018

so, in the second case do you want to update the same data-info attribute with a new key, right?

since data-info has a string as a type value, first you need to get it and parse to an object.

const dataInfoObject = JSON.parse(this.model.get('data-info'))

after that, you can update the object with the new key

dataInfoObject[newKey] = newValue

and then you change it back to string and replace the attribute value for your model

this.model.set('data-info', JSON.stringfy(dataInfoObject))

let me know if it works

artfAugust 31, 2018

I thinks he's just looking for addAttributes

lock[bot]September 17, 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.