C # Error Edit detail

0

Currently I have an error to edit the detail of an order, I want to pass the field iCode which is the code of the detail, but with this code I have the error that passes the code of the header of the order.

In my view the detail is as follows:

<tbody style="background-color:#f1f8f8" data-bind="foreach: items">
                        <tr>
                            <td data-bind="text: iCode"></td>
                            <td data-bind="text: strName"></td>
                            <td data-bind="text: iQuantity"></td>
                            <td><a href="#" @{ if (Model.iShow > 0)
                                            { <text> style="visibility:hidden" </text> } } data-bind="click: $parent.EditDetalle">
                                            <i class="glyphicon glyphicon-pencil"></i>
                                </a>
                            </td>
                        </tr>
                    </tbody>

The code in javaScript is as follows:

self.EditDetalle = function () {
                        event.preventDefault();
                        debugger;
                        var sCode = $("#iCode").val()
                        window.location.href = "/Admin/ManagementRequest?iCode=" + sCode;
                    };
                    
asked by DAES 26.06.2017 в 16:42
source

1 answer

0

I do not know much about knockout.js but I can see that you have a problem here:

 var sCode = $("#iCode").val()

In the html that you show us there is not an element with the id iCode but a binding so it would be impossible to jQuery get the value of an input that does not exist.

Modify the html so that a input[hidden] can save the value of iCode :

<tbody style="background-color:#f1f8f8" data-bind="foreach: items">
                        <tr>
                            <td data-bind="text: iCode">
               <input type="hidden" id="iCode" data-bind="{ value: iCode }" />

                     </td>
                            <td data-bind="text: strName"></td>
                            <td data-bind="text: iQuantity"></td>
                            <td><a href="#" @{ if (Model.iShow > 0)
                                            { <text> style="visibility:hidden" </text> } } data-bind="click: $parent.EditDetalle">
                                            <i class="glyphicon glyphicon-pencil"></i>
                                </a>
                            </td>
                        </tr>
                    </tbody>

I can not confirm that the binding will work (I have not done a disaster with knockout.js for a long time), but is for you to have an idea of what you should do to make it work with jQuery .

    
answered by 26.06.2017 в 17:15