grapesjs icon indicating copy to clipboard operation
grapesjs copied to clipboard

Help Wanted : On Trait update

Open vishal5033 opened this issue 8 years ago • 2 comments

Hello,

I have applied a href trait on image tag. Can you please tell me which event fires when href trait is changed for that.

Thanks,

vishal5033 avatar Dec 15 '17 12:12 vishal5033

Hi @vishal5033,

The component:update event should get triggered when a trait changes, but it's also going to fire when anything changes. You could check for the specific trait (href) by inspecting the changed property of the component object that's passed to the callback. Maybe something like this:

editor.on("component:update", function(component) {
  if (component.changed && component.changed.attributes && component.changed.attributes.href) {
    console.log("href changed!", component);
  };
})

ryandeba avatar Dec 16 '17 00:12 ryandeba

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 18 '19 04:09 lock[bot]