var EditDialog = function (parent) { this.Parent = parent; this.Setup = function () { $("#sex span").on("click", this.OnSexButtonClick.bind(this)); $("#edit-sure-btn").on("click", this.OnSureButtonClick.bind(this)); $("#edit-cancel-btn").on("click", this.HideDialog.bind(this)); $("#edit-close").on("click", this.HideDialog.bind(this)); }; this.Show = function (data) { $('#edit-dialog').show(); $("#username").textbox('setValue', data.Name); $("#account").textbox('setValue', data.LoginAccount); $("#pass").textbox('setValue', data.LoginPassword); $('#sex span').eq(0).attr('type') === data.Sex ? $('#sex span').eq(0).addClass('active') : $('#sex span').eq(0).removeClass('active'); $('#sex span').eq(1).attr('type') === data.Sex ? $('#sex span').eq(1).addClass('active') : $('#sex span').eq(1).removeClass('active'); }; this.OnSexButtonClick = function (event) { $('#sex span').removeClass("active"); $(event.target).addClass("active"); }; this.OnSureButtonClick = function () { $('#edit-dialog').hide(); }; this.HideDialog = function () { $('#edit-dialog').hide(); }; };