Daniel Ellison
Daniel Ellison

Reputation: 1347

Knockout JS - Delete button not binding correctly

Hi folks I have a CRUD system I am working on and most of it I got working but for some reason the delete bind dosent seem to work.

This is the error i get in the console:

Uncaught SyntaxError: Unable to parse bindings.
Bindings value: click: delete
Message: Unexpected token }

Here is an example of what my site code looks like:

http://jsfiddle.net/rqwku4kb/2/

This is the code thats giving me headaches:

Incident.prototype.delete = function(IncidentToRemove) {
    var id = this.ID,
        url = Incident.BASE_URL + (id ? '(' + encodeURIComponent(id) + ')' : '');

    return $.ajax(url, {
        type: 'DELETE',
        dataType: 'json',
        data: ko.toJSON({
            Description: this.Description,
            Incident: this.Incident
        }),
        success: function (data) {
                    console.log("Record was sucessfully saved.");
                    self.incidents.remove(IncidentToRemove);
                    $('#myModal').modal('hide');
                    }
    });
};

I feel like it's something silly but nothing obvious is catching my attention. Would anyone know where the issue might be?

Upvotes: 0

Views: 184

Answers (1)

Joel R Michaliszen
Joel R Michaliszen

Reputation: 4222

The delete is a reserved keyword, try to use another name. See JavaScript Reserved Words, but if you really want to use the delete as a function name, you can do that Reserved words usage in JS.

Upvotes: 1

Related Questions