grapesjs icon indicating copy to clipboard operation
grapesjs copied to clipboard

about the use of setAttributes

Open ionic666 opened this issue 8 years ago • 3 comments

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

ionic666 avatar Aug 27 '18 07:08 ionic666

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

arthuralmeidap avatar Aug 30 '18 14:08 arthuralmeidap

I thinks he's just looking for addAttributes

artf avatar Aug 30 '18 21:08 artf

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.

lock[bot] avatar Sep 17 '19 07:09 lock[bot]