-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Buttons are not working #5
Comments
Hi @tomadmiraal I have to update the documentation. Thanks for the feedback. This code works well <!DOCTYPE html>
<html lang="nl" dir="ltr">
<head>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/davicotico/[email protected]/dist/styles.min.css">
<script src="https://cdn.jsdelivr.net/gh/davicotico/[email protected]/dist/menu-editor.min.js"></script>
</head>
<body>
<div id="navigation-items"></div>
<script>
var items = [{"text":"Home","href":"/home","icon":"fa-solid fa-house","tooltip":"Go to home page","children":[]},{"text":"About Us","href":"/about","icon":"fa-solid fa-address-card","tooltip":"Learn more about our company","children":[]},{"text":"Services","href":"/services","icon":"fa-solid fa-gear","tooltip":"Discover the services we offer","children":[{"text":"Service 1","href":"/services/1","icon":"cog","tooltip":"Details for Service 1","children":[]},{"text":"Service 2","href":"/services/2","icon":"cog","tooltip":"Details for Service 2","children":[]}]},{"text":"Products","href":"/products","icon":"fa-solid fa-cart-shopping","tooltip":"View our available products","children":[{"text":"Product 1","href":"/products/1","icon":"shopping-cart","tooltip":"Details for Product 1","children":[]},{"text":"Product 2","href":"/products/2","icon":"shopping-cart","tooltip":"Details for Product 2","children":[]}]}];
const menuEditor = new MenuEditor('navigation-items', { maxLevel: 3 });
menuEditor.onClickDelete((event) => {
console.log('onClickDelete')
});
menuEditor.onClickEdit((event) => {
console.log('onClickEdit')
});
menuEditor.setArray(items);
menuEditor.mount();
let output = menuEditor.getString();
console.log(output);
</script>
</body>
</html> |
Hi @davicotico, Perfect, it's working now! This was not in the documentation indeed. Can you also add type="button" to the buttons? The buttons will trigger the form submit if there is an form around. It may also be an option to change the buttons into links with the btn classes? That will kill any problem with form submits |
I've created a small demo:
This is as clean as posible, but when I push the edit or delete button, no log will be created in the console.
What am I missing here?
The text was updated successfully, but these errors were encountered: