KnockoutJS不绑定已自动完成的字段

时间:2018-11-22 13:02:13

标签: c# knockout.js

我正在使用获取公司数据的外部文件。自动完成工作正常,输入被填充。但是,当我将页面保存到数据库中时,所有自动完成的字段都不会被绑定。

class App extends Component {
    constructor(props) {
        super(props);

        this.state = {
            borderColor: 'white',
            active_id: null
        };
}


    handleProductSelect(productId) {
        const { borderColor } = this.state;
        let newBorderColour = borderColor === 'white' ? 'blue' : 'white';
        this.setState({
            borderColor: newBorderColour,
            active_id: productId
        })
    }

render {
return(
    (price.map(p =>
        <div key={p.productId}>
            <div
                style={{ 
                    borderRadius: '10%',
                    borderStyle: 'solid',
                    padding: '10px',
                    marginBottom: 10,
                    p.productId === this.state.active_id ? { borderColor: this.state.borderColor} : {borderColor : 'white'}
                 }}


                onClick={(p)=> this.handleProductSelect(p.productId)}>
                <div>{p.displayName}</div><br />
                <div>{p.imageUrl !== '' ? p.imageUrl : <img style={{ width: '100px', height: '50px' }} src={"https://source.unsplash.com/200/150"} />}</div><br />
            </div>
        </div>
    ))
    }
)}

缺少的数据在“订单”内部。只要更改输入内容,数据就会被提取。我尝试使用“ valueUpdate:'输入'”,但到目前为止没有成功。

这是我的自动填充代码:

 public Save(saveorder: Boolean): void {
    let order: Order = ko.toJS(OrderPage.Instance().Order);
    let date = OrderPage.Instance().Order.DateAccepted;
    let removefromorderlines: Array<number> = [];
    OrderPage.Instance().j$.each(order.OrderLines, (index: number, orderline: OrderLine) => {
        // Check if there are any orderlines that don't have a modelid 
        if (orderline.ArticleModelId == null) {
            removefromorderlines.push(index);
        } 
    });
    let previousindex: any = 0;
    $.each(removefromorderlines, (index: number, orderlineindex: number) => {
        order.OrderLines.splice(orderlineindex - previousindex, 1);
        previousindex++;
    });
    if (saveorder == true) {
        OrderPage.Instance().ToggleDisableButton('btnSaveOrder', true);
        webApi.Execute(HttpRequestType.Post, '/Order/SaveOrder', order, OrderPage.Instance().OnSaveSuccess, OrderPage.Instance().OnSaveError);
    }

} 让kvkfactory:Services.kvkFactory;

0 个答案:

没有答案