Click here to Skip to main content
15,888,590 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,


I have a listing page. and in that page i have a button to add new item.
When i click on the add new button, a popup displays and in that popup i need to add the new item and save.


Popup contains textboxes and dropdown controls. Now when i click save the data entered in textboxes get saved but the selected data from dropdown is not getting saved. Please help me to do this.

This the code what i have written:


In API controller:

XML
public HttpResponseMessage Post(TKTJOB job)
        {

            HelpDeskRepository.AddJob(job);
            var response = Request.CreateResponse<TKTJOB>(HttpStatusCode.Created, job);
            string uri = Url.Link("DefaultApi", new { id = job.JobId });
            return response;
        }



In My.js

$(document).ready(function () {
    ko.applyBindings(new HelpDesk(), document.getElementById('full'));
});
function HelpDesk() {
    var self = this;
    self.JobID=0 ;
    self.CategoryId=0;
    self.JobTitle="";
    self.JobDesc="";
      
    self.category = ko.observable([]);
    self.categorySelected = ko.observable();
        $.getJSON("api/helpdeskapi/getCategory", function (data) {
        self.category(data);
    });
   
    self.addTicket = function () {
        $.ajax({
            url: "api/helpdeskapi/Post",
            type: 'post',
            data: ko.toJSON(this),
            contentType: 'application/json',
            success: function (result) { }
        });
    }
}



In popup:

<select style = "font-size: 12px; font-weight: normal;" data-bind="options: category, optionsText: 'Category',optionsValue: 'CategoryId',Value: categorySelected,  optionsCaption: '........Select........'"></select>
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900