Closed HarshOB closed 7 years ago
This is how traits should work. When you update the value of the trait that change is reflected up to the component (example of input type in select component https://github.com/artf/grapesjs-plugin-forms/blob/master/src/components.js#L70-L78)
Let's say I made custom component and add that to grapes editor then I want to change body(You can say whole HTML/CSS) of that component using selected value in the drop-down from traits. Is it possible?
Well, yeah, you can create traits with changeProp
, then add a listener on that property change (inside Component's model) which triggers the appropriate action
I tried that. I write one function inside the model to change existing component.
// Edit
blockManager.get('productListing').set({
label: 'Updated simple block',
content: response
});
But this will not update that current component. When I drag same component again then It will reflect the change. What can I do to reflect the changes on the current window?
I think you're confusing blocks with components, read first about Blocks and Components
What I want is when user select any templates from the drop-down(shown on right side) then that template will be loaded from template folder(shown on the left side) and on the fly, it will reflect on a window without reloading. Hope this will clarify what my requirement is.
ok, what about editor.setComponents('<div>...</div>')
?
@artf Well, yeah, you can create traits with changeProp, then add a listener on that property change (inside Component's model) which triggers the appropriate action What property changes when selecting something different for dropdown menus.
Created listener for name/value/selectedComponent/and component:update:content none worked
format was this.listenTo(this, 'change: x', this.myFunction)
myFunction(){ //do stuff }
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.
Like If I created drop-down in traits and with a select value of dropdown I want to change the text that is present in that component without reloading or dragging that component again.