Javascript 敲除JS-将绑定数据发布到我的表

Javascript 敲除JS-将绑定数据发布到我的表,javascript,jquery,knockout.js,Javascript,Jquery,Knockout.js,嗨,伙计们,我是一个新的击倒和学习,因为我去。我设法通过JSFIDLE在我的站点上重新创建了我想要完成的任务。我复制了代码并将其放入我的站点,唯一的区别是我通过AJAX从服务器获取数据 现在发生的情况是,我的表使用“编辑”按钮在表中创建了一行,但没有呈现任何文本绑定。我相信Ajax的某些特性导致了这些问题,但我不知道是什么原因 有人有什么线索吗 控制台错误消息: Uncaught ReferenceError: Unable to process binding "text: function

嗨,伙计们,我是一个新的击倒和学习,因为我去。我设法通过JSFIDLE在我的站点上重新创建了我想要完成的任务。我复制了代码并将其放入我的站点,唯一的区别是我通过AJAX从服务器获取数据

现在发生的情况是,我的表使用“编辑”按钮在表中创建了一行,但没有呈现任何文本绑定。我相信Ajax的某些特性导致了这些问题,但我不知道是什么原因

有人有什么线索吗

控制台错误消息:

Uncaught ReferenceError: Unable to process binding "text: function (){return Incident }"
Message: Incident is not defined
HTML代码:

<table class="table table-bordered table-hover text-center" id="example2">
    <thead>
        <tr>
            <th width="30" class="text-center"><i class="fa fa-list-alt fa-4"></i></th>
            <th width="75" class="text-center"> Incident <i class="fa fa-ticket"></i> </th>
            <th width="65" class="text-center"> Priorité <i class="fa fa-balance-scale"></i> </th>
            <th width="70" class="text-center"> Composante <i class="fa fa-building-o"></i> </th>
            <th width="300" class="text-center"> Description <i class="fa fa-ellipsis-h"></i> </th>
            <th width="100" class="text-center"> Date de début <i class="fa fa-calendar"></i> </th>
            <th width="100" class="text-center"> Responsable <i class="fa fa-user"></i> </th>
        </tr>
    </thead>
    <tbody data-bind="template: { name: 'Incidents', foreach: dataFromServer() }" />
    </tbody>
</table>

发生的事情
优先权
沉着
描述
戴布特日期
负责的
我的模板代码:

<script type="text/html" id="Incidents">
<tr>
    <td class='over_flow_control'><button class='edit_button btn btn-default btn-sm' type='button' value='Edit' data-bind="click: $parent.editProduct"><i class='glyphicon glyphicon-edit'></i></button></td>
    <td class='over_flow_control' data-bind="text: Incident"></td>
    <td class='over_flow_control'><h4><span class='priorité_span' data-bind="text:PrioritéValue"></span></h4></td>
    <td class='over_flow_control' data-bind="text:Composante"></td>
    <td class='over_flow_control text-left' data-bind="text:Description"></td>
    <td class='over_flow_control Date_de_début_cell' data-bind="text:Date_de_début"></td>
    <td class='over_flow_control' data-bind="text:ResponsableValue"></td>    
</tr>
</script>

我的javascript代码:

<script type="text/javascript">
function load_incidents(ID, Description, Composante, Incident, ÉtatValue, PrioritéValue, Duré, Date_de_début, Date_de_fin, Groupe_Support_Prime, Autres_Groupe_Support_Prime, ResponsableValue, Impact, Temps_Consacré, Type_de_tempsValue, Journal_des_actions, Dépanage, Suivi, Ressources) {
    var self = this;
    this.ID = ID;
    this.Description = ko.observable(Description);
    this.Composante = ko.observable(Composante);
    this.Incident = ko.observable(Incident);
    this.ÉtatValue = ko.observable(ÉtatValue);
    this.PrioritéValue = ko.observable(PrioritéValue);
    this.Duré = ko.observable(Duré);
    this.Date_de_début = ko.observable(Date_de_début);
    this.Date_de_fin = ko.observable(Date_de_fin);
    this.Groupe_Support_Prime = ko.observable(Groupe_Support_Prime);
    this.Autres_Groupe_Support_Prime = ko.observable(Autres_Groupe_Support_Prime);
    this.ResponsableValue = ko.observable(ResponsableValue);
    this.Impact = ko.observable(Impact);
    this.Temps_Consacré = ko.observable(Temps_Consacré);
    this.Type_de_tempsValue = ko.observable(Type_de_tempsValue);
    this.Journal_des_actions = ko.observable(Journal_des_actions);
    this.Dépanage = ko.observable(Dépanage);
    this.Journal_des_actions = ko.observable(Journal_des_actions);
    this.Suivi = ko.observable(Suivi);
    this.Ressources = ko.observable(Ressources);

    //This is the start edit group//
    this.editDescription = ko.observable(Description);
    this.editComposante = ko.observable(Composante);
    this.editIncident = ko.observable(Incident);
    this.editÉtatValue = ko.observable(ÉtatValue);
    this.editPrioritéValue = ko.observable(PrioritéValue);
    this.editDuré = ko.observable(Duré);
    this.editDate_de_début = ko.observable(Date_de_début);
    this.editDate_de_fin = ko.observable(Date_de_fin);
    this.editGroupe_Support_Prime = ko.observable(Groupe_Support_Prime);
    this.editAutres_Groupe_Support_Prime = ko.observable(Autres_Groupe_Support_Prime);
    this.editResponsableValue = ko.observable(ResponsableValue);
    this.editImpact = ko.observable(Impact);
    this.editTemps_Consacré = ko.observable(Temps_Consacré);
    this.editType_de_tempsValue = ko.observable(Type_de_tempsValue);
    this.editJournal_des_actions = ko.observable(Journal_des_actions);
    this.editDépanage = ko.observable(Dépanage);
    this.editJournal_des_actions = ko.observable(Journal_des_actions);
    this.editSuivi = ko.observable(Suivi);
    this.editRessources = ko.observable(Ressources);

    //end of the edit group//
    this.accept = function () {
    this.Description(this.editDescription());
    this.Composante(this.editComposante());
    this.Incident(this.editIncident());
    this.ÉtatValue(this.editÉtatValue());
    this.PrioritéValue(this.editPrioritéValue());
    this.Duré(this.editDuré());
    this.Date_de_début(this.editDate_de_début());
    this.Date_de_fin(this.editDate_de_fin());
    this.Groupe_Support_Prime(this.editGroupe_Support_Prime);
    this.Autres_Groupe_Support_Prime(this.editAutres_Groupe_Support_Prime());
    this.ResponsableValue(this.editResponsableValue());
    this.Impact(this.editImpact());
    this.Temps_Consacré(this.editTemps_Consacré());
    this.Type_de_tempsValue(this.editType_de_tempsValue());
    this.Journal_des_actions(this.editJournal_des_actions());
    this.Dépanage(this.editDépanage());
    this.Journal_des_actions(this.editJournal_des_actions());
    this.Suivi(this.editSuivi());
    this.Ressources(this.editRessources());
    return true;
    }.bind(this);

    //reset to originals on cancel
    this.cancel = function () {
    this.editDescription(this.Description());
    this.editComposante(this.Composante());
    this.editIncident(this.Incident());
    this.editÉtatValue(this.ÉtatValue());
    this.editPrioritéValue(this.PrioritéValue());
    this.editDuré(this.Duré());
    this.editDate_de_début(this.Date_de_début());
    this.editDate_de_fin(this.Date_de_fin());
    this.editGroupe_Support_Prime(this.Groupe_Support_Prime);
    this.editAutres_Groupe_Support_Prime(this.Autres_Groupe_Support_Prime());
    this.editResponsableValue(this.ResponsableValue());
    this.editImpact(this.Impact());
    this.editTemps_Consacré(this.Temps_Consacré());
    this.editType_de_tempsValue(this.Type_de_tempsValue());
    this.editJournal_des_actions(this.Journal_des_actions());
    this.editDépanage(this.Dépanage());
    this.editJournal_des_actions(this.Journal_des_actions());
    this.editSuivi(this.Suivi());
    this.editRessources(this.Ressources());
    }.bind(this);
}

Incidents = {
pvm: {},
productStore: {
    products: [],
    init: function (data) {
        this.products = $.map(data, function (product) {
            return new load_incidents(product.ID, product.Description(), product.Composante());
        });
        console.log(this.products);
    }
},  

init: function () {

var self = this;
dataFromServer = ko.observableArray([]);
$.getJSON("../../../../_vti_bin/listData.svc/GDI_PROD_Incidents?$filter=ÉtatValue%20ne%20%27Fermé%27&$orderby=PrioritéValue desc",
function (data) {
if (data.d.results) {
dataFromServer(JSON.stringify(data.d.results));
console.log(dataFromServer());
}
}
);
Incidents.productStore.init(dataFromServer());
},
productViewModel: function (data) {
        var self = this;
        var productsArray = [];

            productsArray = data;

        this.products = ko.observableArray(productsArray);
        this.selectedProduct = ko.observable();
        this.editProduct = function (productToEdit) {
            self.selectedProduct(productToEdit);

            // Incidents.pvm.selectedProduct(productToEdit);
        };
        this.acceptEdit = function () {
            var selected = Incidents.pvm.selectedProduct();
            if (selected.accept()) {
                Incidents.pvm.selectedProduct("");
                $('#dialogEditProduct').popup('close');
            }
        };
        this.cancelEdit = function () {
            Incidents.pvm.selectedProduct().cancel();
            Incidents.pvm.selectedProduct("");
            $('#dialogEditProduct').popup('close');
        };
    }
};
ko.bindingHandlers.jqButton = {
    init: function (element) {
        $(element).button();
    },
    update: function (element, valueAccessor) {
        var currentValue = valueAccessor();
        $(element).button("option", "disabled", currentValue.enable === false);
    }
};

ko.bindingHandlers.openProductDialog = {
    update: function (element, valueAccessor) {  
        var value = ko.utils.unwrapObservable(valueAccessor());
        if (value) {
            $.mobile.changePage("#dialogEditProduct", {
                role: 'dialog'
            });
            $("#dialogEditProduct").open();    
            // $("#dialogEditProduct").trigger('create');    
        }

    }
};

$.extend({
    isNumber: function (obj) {
        return !isNaN(parseFloat(obj)) && isFinite(obj);
    }
});

Incidents.init(); 
ko.applyBindings(Incidents);
</script>

功能负载事件(ID、描述、成分、事件、状态值、优先级值、Duré、日期但、日期财务、组支持、组支持、责任值、影响、临时消费、类型临时值、日志、行动、数据处理、Suivi、资源){
var self=这个;
this.ID=ID;
此描述=可观察(描述);
这个.Composante=ko.可观察(Composante);
本事件=可观察到的(事件);
该值=可观测的ko值(单位:单位:单位:单位:单位:单位:单位:单位:单位:单位:单位:单位:单位:单位:单位:单位:单位:单位:单位:单位:单位:单位:单位:单位:单位:单位:单位:单位:单位:;
该优先权价值=可观察的ko(优先权价值);
这个Duré=可观察的ko(Duré);
此.Date_de_édébut=ko.可观察(Date_de_édébut);
此日期=可观察的ko(日期);
this.Groupe_Support_Prime=ko.observable(Groupe_Support_Prime);
this.Autres_Groupe_Support_Prime=ko.observable(Autres_Groupe_Support_Prime);
该责任值=可观察到的ko(责任值);
该影响=可观察到的(影响);
这个.Temps_Consacré=ko.可观察(Temps_Consacré);
this.Type_de_tempsValue=ko.observable(Type_de_tempsValue);
this.Journal_des_actions=ko.可观察(Journal_des_actions);
这个Dépanage=ko.可观察(Dépanage);
this.Journal_des_actions=ko.可观察(Journal_des_actions);
this.Suivi=ko.observable(Suivi);
该资源=可观测的(资源);
//这是开始编辑组//
this.editDescription=ko.可观察(描述);
this.editComposante=ko.可观察(Composante);
this.editIncident=ko.可观察(事件);
本.编辑ÉtatValue=ko.可观察(ÉtatValue);
此.editPriorité值=ko.可观察(Priorité值);
这个.editDuré=可观察的ko(Duré);
this.editDate_de_deédébut=ko.observable(Date_de_édébut);
this.editDate_de_fin=ko.可观察(Date_de_fin);
this.editGroupe_Support_Prime=ko.observable(Groupe_Support_Prime);
this.editAutres_Groupe_Support_Prime=ko.observable(Autres_Groupe_Support_Prime);
this.editResponsableValue=ko.可观察(ResponsableValue);
this.editImpact=ko.可观察(影响);
这个.editTemps_Consacré=ko.可观察(Temps_Consacré);
this.editType_de_tempsValue=ko.可观察(Type_de_tempsValue);
this.editJournal_des_actions=ko.可观察(Journal_des_actions);
这个.editDépanage=ko.可观察(Dépanage);
this.editJournal_des_actions=ko.可观察(Journal_des_actions);
this.editSuivi=ko.可观察(suvi);
this.EditResources=ko.可观察(Resources);
//编辑组结束//
this.accept=函数(){
this.Description(this.editDescription());
this.Composante(this.editComposante());
this.Incident(this.editIncident());
this.etavalue(this.edit etavalue());
this.PrioritéValue(this.editPrioritéValue());
this.Duré(this.editDuré());
this.Date_de_édébut(this.editDate_de_édébut());
this.Date_de_fin(this.editDate_de_fin());
this.Groupe\u Support\u Prime(this.editGroupe\u Support\u Prime);
this.Autres_Groupe_Support_Prime(this.editAutres_Groupe_Support_Prime());
this.ResponsableValue(this.editResponsableValue());
this.Impact(this.editImpact());
this.Temps_Consacré(this.editTemps_Consacré());
this.Type_de_tempsValue(this.editType_de_tempsValue());
this.Journal_des_actions(this.editJournal_des_actions());
this.Dépanage(this.editDépanage());
this.Journal_des_actions(this.editJournal_des_actions());
this.Suivi(this.editSuivi());
this.resources(this.editresources());
返回true;
}.约束(本);
//取消时重置为原稿
this.cancel=函数(){
this.editDescription(this.Description());
this.editComposante(this.Composante());
this.editIncident(this.Incident());
this.editÉtatValue(this.ÉtatValue());
this.editPriorité值(this.Priorité值());
this.editDuré(this.Duré());
this.editDate_de_édébut(this.Date_de_édébut());
this.editDate_de_fin(this.Date_de_fin());
this.editGroupe\u Support\u Prime(this.Groupe\u Support\u Prime);
this.editAutres_Groupe_Support_Prime(this.Autres_Groupe_Support_Prime());
this.editResponsableValue(this.ResponsableValue());
this.editImpact(this.Impact());
this.editTemps_Consacré(this.Temps_Consacré());
this.editType_de_tempsValue(this.Type_de_tempsValue());
this.editJournal_des_actions(this.Journal_des_actions());
this.editDépanage(this.Dépanage());
this.editJournal_des_actions(this.Journal_des_actions());
this.editSuivi(this.suvi());
this.editresources(this.Ressources());
}.约束(本);
}
事件={
pvm:{},
产品商店:{
产品:[],
init:函数(数据){
this.products=$.map(数据、函数(产品){
返回新的加载事件(product.ID、product.Description()、product.Composante());
});
console.log(this.products);
}
},  
init:函数(){
var self=这个;
dataFromServer=ko.observearray([]);
$.getJSON(“../../../../../../../\u vti\u bin/li
var MyVm = function() {
  this.name = ko.observable('John');
  this.age = ko.observable(23);
}
var myVm = new MyVm();
var MyVm = function() {
  this.name = ko.observable('John');
  this.age = ko.observable(23);
  this.incAge = function() {
    this.age(this.age()+1);
  };
}
var MyVm = function() {
  var self = this;
  self.name = ko.observable('John');
  self.age = ko.observable(23);
  self.incAge = function() {
    self.age(self.age()+1);
  };
  return self;
}
var MyVm = function(_name, _age) {
  var self = this;
  self.name = ko.observable(_name);
  self.age = ko.observable(_age);
  self.incAge = function() {
    self.age(self.age()+1);
  };
  return self;
}
    <a href="#" data-bind="click: $parent.removeItem">Delete</a>
productViewModel: function (data) {
    var self = this;
    var productsArray = [];
    if (data && data.length > 0) {
        productsArray = data;
    }
    self.products = ko.observableArray(productsArray);

    this.selectedProduct = ko.observable();

    this.removeItem = function (productToRemove){
        self.products.remove(productToRemove);
    }
                self.products.remove(productToRemove);
                this.products.remove(productToRemove);