asp.net mvc - Backbone save, model data not recieved on the server -


i'm using backbone asp.net mvc. want save model server.

folder model

folder = backbone.relationalmodel.extend({    url: "/savefolder",  relations: [     {         type: backbone.hasmany,         key: 'files', /*key should match json name*/                    relatedmodel: 'filemodel',         collectiontype: 'filecollection',                 } ], idattribute: "folderid" 

});

folder saving code in view

 var newfolder = new folder();     newfolder.set("foldername", newfoldername);     newfolder.set("editablebyothers", "n");     newfolder.save({         success: function(model, response, options) {             alert("success"); //not reached         },         error: function (model, xhr, options) {             alert("error"); //not reached         }     }); 

note: success , error alerts never fire.

when check in fiddler, json being sent -

{"files":[],"foldername":"new","editablebyothers":"y"} 

my controller on serverside, however, recieves empty folder object -

    [httppost]     public actionresult savefolder(folder newfolder) //all properties of newfolder null, or "n" in case of boolean     {         string name = newfolder.foldername;         return null;     } 

folder class on server -

public class folder {     public int? folderid { get; set; }     public int userid;             public string foldername;     public bool editablebyothers;     public ilist<file> files; } 

i can't point @ what's fishy here. again, i'm backbone newbie, have missed something. can see what's wrong?

the main problem having public fields on model instead of properties. simple issue, not simple locate. post helped me - how pass complex type using json asp.net mvc controller


Comments

Popular posts from this blog

java - Run a .jar on Heroku -

java - Jtable duplicate Rows -

validation - How to pass paramaters like unix into windows batch file -