pau_cuiner How Into > asig_to_item > action call exrternal function
I have a new version coming out soon in 1-2 weeks, and you might want to know that I have fixed and improved the custom contextmenu button options. It will work like this from _files/js/custom.js
:
_c.config = {
contextmenu: { /* all custom button objects must go inside here */ }
}
Minimal button object requirements:
// creates a button with text "Log" that logs the clicked item properties into browser log.
log: {
action: (item) => console.log(item)
}
Extended object example:
// creates a button that opens images in new window on click.
mybutton: {
// actual text of the button, defaults to the key "mybutton" if not assigned.
text: 'Open in new window!',
// optional svg icon, currently undocumented.
icon: 'image',
// optional condition that decides if the button should display or not.
// in the below example, the button will only appear for images
condition: (item) => {
return item.browser_image;
},
// action to run when button is clicked
action: (item) => {
yourFunction(item);
},
// The button will be <a href="..."> instead of <button>, and action will be ignored.
href: (item) => {
return item.url_path; // causes the image to open in new window on click.
},
// options className to assign to button for custom styling
class: 'mybutton'
}
In the above properties condition
, action
and href
, the item
object is returned with information about the click item that you can act upon.