Adding event handlers to buttons in foreignObject html #2681
-
IntroductionI'm using html in ports (via foreignObject) - is there a (recommended/supported) way to attach event handlers to buttons using jointjs? Or should I build this part using svg support? Steps to reproduceNo response Restrictions & ConstraintsNo response Does your question relate to JointJS or JointJS+. Select both if applicable.JointJS |
Beta Was this translation helpful? Give feedback.
Answered by
kumilingus
Jun 4, 2024
Replies: 1 comment 3 replies
-
Here's our tutorial on HTML shapes. You need to add a custom element view. Here's an example: const FormView = dia.ElementView.extend({
events: {
'submit form': 'onSubmit',
'change input': 'onChange'
},
onSubmit: function (evt) {
evt.preventDefault();
this.model.attr('name/props/value', '');
},
onChange: function (evt) {
this.model.attr('name/props/value', evt.target.value);
}
}); |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
There is no difference. The element view contains the element and the ports.
Each port has
.joint-port
class.