grapesjs icon indicating copy to clipboard operation
grapesjs copied to clipboard

Listen to any change in the canvas

Open milapshah15 opened this issue 8 years ago • 8 comments

Hello Folks,

I have a requirement where I added a button which saves the configuration to the remote DB.Now I would like to listen to any change in the canvas to enable/disable the button.For example, If there is any change, enable the save button for user to save it.I have gone through available events but I found nothing which listen to any change (Style,Component add/remove).

Any help? @artf

Warm regards Milap

milapshah15 avatar May 31 '18 22:05 milapshah15

I'm not sure if there's one exclusive event that listens for any changes to the canvas. Perhaps you could have your method run on all of the canvas events instead?

https://github.com/artf/grapesjs/blob/dev/src/editor/index.js#L53 `* ## Canvas

    • canvas:dragenter - When something is dragged inside the canvas, DataTransfer instance passed as an argument
    • canvas:dragover - When something is dragging on canvas, DataTransfer instance passed as an argument
    • canvas:drop - Something is dropped in canvas, DataTransfer instance and the dropped model are passed as arguments
    • canvas:dragend - When a drag operation is ended, DataTransfer instance passed as an argument
    • canvas:dragdata - On any dataTransfer parse, DataTransfer instance and the result are passed as arguments.`

IStirton10 avatar Jun 01 '18 00:06 IStirton10

Actually I think there is an event that could serve this purpose. Could you try defining your method callback on 'change:changesCount'?

grapesjs\src\editor\model\Editor.js:64 this.on('change:changesCount', this.updateChanges, this);

IStirton10 avatar Jun 01 '18 00:06 IStirton10

@IStirton10 Let me try it out.I guess this should work.

Warm regards Milap

milapshah15 avatar Jun 01 '18 15:06 milapshah15

@IStirton10 Its working.Thank you.

Is there a method which makes button disabled and not clickable.The Enable property is just about making it selected.Do we have anything to disable the button.

@artf Any thoughts?

Warm regards Milap

milapshah15 avatar Jun 01 '18 16:06 milapshah15

@milapshah15 hi ,bro.i am doing this.Have you implemented the disable button function

ionic666 avatar Jun 11 '18 03:06 ionic666

Its working.Thank you.

I'm closing this then

Is there a method which makes button disabled and not clickable.The Enable property is just about making it selected.Do we have anything to disable the button.

btnModel.set('disable', true);

artf avatar Jun 13 '18 20:06 artf

@ionic666 No I did not find any method which can disable the button

Warm regards Milap

milapshah15 avatar Jun 13 '18 21:06 milapshah15

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 13:09 lock[bot]