Knockout JS - How to return empty strings for observable fields
Ad
Im building a CRUD system where users can add, delete and edit data from a simple table. I have a modal form that is used to show additional details and also adding new incidents. Currently the modal form loads correctly for editing but has issues when trying to add a new incident.
After some debuging it seems that the issue comes from this line:
self.currentIncident(null);
This breaks my modal form because my observable is coming back null (obviously). I was hoping that it would return something like the following:
"ID": "",
"Description": "",
"Incident": ""
I believe this is why my modal is crashing since my modal is confused with the return. Would someone know of an easy method to return empty strings?
self.AddNewIncident = function() {
var id = this.ID;
self.showModal(true);
self.currentIncident(null);
};
Here is jsfiddle: http://jsfiddle.net/rqwku4kb/12/
Ad
Answer
Ad
Ad
source: stackoverflow.com
Related Questions
Ad
- → How to update data attribute on Ajax complete
- → October CMS - Radio Button Ajax Click Twice in a Row Causes Content to disappear
- → Octobercms Component Unique id (Twig & Javascript)
- → Passing a JS var from AJAX response to Twig
- → Laravel {!! Form::open() !!} doesn't work within AngularJS
- → DropzoneJS & Laravel - Output form validation errors
- → Import statement and Babel
- → Uncaught TypeError: Cannot read property '__SECRET_DOM_DO_NOT_USE_OR_YOU_WILL_BE_FIRED' of undefined
- → React-router: Passing props to children
- → ListView.DataSource looping data for React Native
- → Can't test submit handler in React component
- → React + Flux - How to avoid global variable
- → Webpack, React & Babel, not rendering DOM
Ad