jquery - Knockout: edited input fields are not updated -


I keep a list of users, whose expansions have been shown in the Bootstrap dialog. The list is properly populated and the details data is shown correctly. But as soon as I update one or more input fields, I will close the dialog and open the details of another user, I will see the edit value instead of the other user's value. If I open the details without editing anything, then I always see the correct value.

Problem: In the case of editing an input field, the selected user (shown in detail) is not overwritten has been done.

View modell:

  function UserViewModel () {// init var self = this; Self.userList = ko.observableArray ([]); Self.selectedUser = ko.observable ([]); Self.availableGroups = ko.observableArray ([]); Self. Errs = Ko. Ossebel Ere ([]); Self.loadUserList = function ($ .ajax ({type: "POST", url: "/user/loadUserList.htm", success: function (response) {var parsedJSON = $ .parseJSON (feedback); self.userList (Ko.mapping.fromJS (parsedJSON));},}); } Self.loadUserDetail = function (user) {// select the selected user yourself. User (ko.mapping.fromJS (user)); // Load Available Group $ .Agx ({Type: "Post", URL: "/ User / Load Allegiance Groups HTM", Success: Function (Response) {Var Persed JSON = $. PRJSANS (Reverse); SIF Group Mapping.frames (ParsedJSON); RegisterClickLister (); EndordiniNutLips (); $ ("# User-Dialog"). Model ('Show');},}); } Self.addUser = function {self.loadUserDetail (ko.observable ([])); $ ("# User communication") model ('show'). } Self.saveUser = function () {// Select All Allowed Group $ ('#sched-select option') Prop ('selected', true); Var formJson = $ ("# User-Form"). SerializeArray (); $ .Azax ({Type: "Post", URL: "/ User / SUUUSAR HTM", Data: FormJason, Success: Function (Response) {var parsedJSON = $ .. PRJSANS (feedback); if (ParsedJSONRars.Lambi == 0) {$ ("# user-dialog"). Modal ('hide');} and {initErrorTooltips ();}}, error: function (e) {showErrorBox ('error:' + E.Stats) ;}}); } Self.cancel = function () {$ ("# User-Dialog"). Model ('Hide'); }}  

HTML:

  & lt; Div class = "form-group-in-alert" & gt; & Lt; Label class = "control-label" & gt; & Lt; Spring: Message code = "masterdata.user.firstName" /> gt; & Lt; / Label & gt; & Lt; Input type = "text" class = "form-control input-sm" data-bound = 'atri: {values: selected users (). FirstName} 'name = "user.firstName" /> & Lt ;! - Forward: Errors () - & gt; & Lt ;! - ko if: key === 'user.firstName' - & gt; & Lt; Span data-bind = 'text: value' class = "spring-error fa fa-lg fa-exclamation-circle" & gt; & Lt; / Span & gt; & Lt ;! - / ko - & gt; & Lt ;! - / ko - & gt; & Lt; / Div & gt;  

The HTML snippets you provided do not show how the model is opened and What happens first and later However, I advise you to use your form elements instead of inert binding.


Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -