Skip to content

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