locked
knockout Js partial view binding problem RRS feed

  • Question

  • User1308732545 posted


    Hello All ,

    I have scenario like this :

    There is a page in which I have two tabs 1 & 2 .
    There are permissions to view these tabs Permissions A & B

    If the user has both the permissions they can see both the tabs , if the user has permission B then they can only view 2 as a page and not a as a tab

    The data-binding for tabs is done using knockout js
    This code looks like this:

        <div id="Tabs">
            @if (condition)// check to see if user has permission , then display 2 tabs 
            {
               
                <div>
                    <ul class="nav nav-tabs" role="tablist">
                        @foreach (var tab in Model.Tabs)
                        {
                            <li role="presentation">
                          <a href="#@tab.PartialName" data-toggle="tab" role="tab" data-bind="click:showpartial.bind($data,'@Url.Action(....)')">@tab.Name</a>
                            </li>
                        }
                    </ul>
                </div>
            }
            else // display patial as a full page
            {
                    Html.Partial(PartialName, Model))            
            }
            <div role="tabpanel" id="tabView" class="tab-pane active">
            </div>       
        </div>


    everything works fine if both the tabs are displayed , the problem arises when the tab is displayed as page

    it throws error "Unable to process bindings"

    Please help

    Thanks

    Thursday, November 10, 2016 12:17 PM

All replies

  • User-693045842 posted

    Seems you are not correct when applying knockout js :

    http://stackoverflow.com/questions/28407961/apply-ko-bindings-to-partial-view

    http://stackoverflow.com/questions/7342814/can-you-call-ko-applybindings-to-bind-a-partial-view

    besides , have you call the tabs?

    <script type="text/javascript">
        $(function () {
            $("#tabs").tabs();
        });
    </script>

    Friday, November 11, 2016 6:58 AM
  • User1308732545 posted

    Hi there , 

    Yeah I am returning the tabs from the controller method 

    Thanks

    Friday, November 11, 2016 9:25 AM
  • User-693045842 posted

    Hi ,

    sorry for the late , have you checked my link ? any update ?

    Tuesday, November 29, 2016 6:56 AM