I'm trying to develop a custom block for the Gutenberg editor. I'm trying to display a button and call a web service then redirect the user to the returned URL. Can anyone please help me why my click handler function is not called?
wp.blocks.registerBlockType('brad/border-box', {
title: 'Simple Box',
icon: 'smiley',
category: 'common',
attributes: {
content: {type: 'string'},
},
/* This configures how the content and color fields will work, and sets up the necessary elements */
edit: function (props) {
function updateContent(event) {
props.setAttributes({content: event.target.value})
}
return React.createElement(
"div",
null,
React.createElement(
"h3",
null,
"Simple Box"
),
React.createElement("input", {type: "number", value: props.attributes.content, onChange: updateContent}),
);
},
save: function (props) {
function clickHandler(event) {
alert('clicked')
}
return wp.element.createElement(
"button",
{style: {padding: '4px', border: '2px solid black'}, onClick: {clickHandler}},
"Click On Me"
);
}
})