Skip to content

Feat - itemAnchorClick #577

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

lofcz
Copy link

@lofcz lofcz commented Jun 23, 2025

Currently, Muuri always opens <a> hrefs when clicked - we needed a mechanism to do this conditionally. Think Jira-like kanban board where items are represented by <a> elements, and the elements contain a checkbox which prevents opening the href:

image

To support this, a new option itemAnchorClick is introduced. If set, this handler enables preventing navigation. We use it like:

itemAnchorClick: function(item, event) {

    // if we clicked on the checkbox, stop
    if (event.target.closest('.kanbanCardCheckbox')) {
        event.preventDefault();
        return false;
    }
    
    let id = item.getElement().getAttribute("data-el-id");
    
    // clicked on the item, navigate (Blazor)
    if (id) {
        pars.net["invokeMethodAsync"]("JsAppNavigation", id);
    }
    
    return false; // return true would result in calling "openAnchorHref" as before this PR
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

1 participant