knockout.js - deferred databinding for modal?

前端 未结 3 1574
-上瘾入骨i
-上瘾入骨i 2020-12-14 03:43

I am using knockout.js to display a list of employees. I have a single hidden modal markup on the page. When the \"details\" button for a single employees is clicked, I wa

3条回答
  •  伪装坚强ぢ
    2020-12-14 04:20

    I would create another observable that wraps the employee.

    this.detailedEmployee = ko.observable({}),
    
    var self = this;
    this.showDetails = function(employee){
        self.detailedEmployee(employee);
        $("#dialog").dialog("show"); //or however your dialog works
    }
    

    Attach the click to showDetails. Then you can just call applyBindings on page load.

提交回复
热议问题