Modify and Call Custom Binding In Knockout.js Expl

2019-09-09 19:47发布

问题:

Can I call the custom binding called form from another custom binding called addAnother explicitly? Also can I modify the parameters going into the parent custom binding?

    ko.bindingHandlers.addAnother = {
        init: function (element, valueAccessor) {
            $(element).click(function () {
                //$(element).parents('form')....
            });
        }
    };

<form class="box clearfix" action="@Request.RawUrl" data-bind="form:{ id: @Model.Division.Id }">
    @Html.Partial("EditorTemplates/Division", Model.Division)
    <div class="control-group">
        <div class="controls">
            @Html.Partial("EditorTemplates/Button")
            <button class="btn btn-inverse" data-bind="addAnother: { }"><i class="icon-save icon-white"></i> Save +</button>

        </div>
    </div>
</form>