javascript - How to replace ' / ' with '-' inside ObservableArray ? Knockout js -


Well, I'm trying to pass an observable array to my controller via AJAX call, But I get every value other than the date I get something like '01 -01-01 '.

I found this problem but unable to fix it because I do not know how to replace / with - .

There are about 10 list items in my observable array, in each list item There are many properties outside startdate , such as ("23/10/2014") just ("23-10-2014") Need something like that.

The thought of posting my function and I hope that in this case I am not required.

I have been explained with a little code and sample data:

  function myarray () {var self = this; Self.startDate = ko.observable (""); Self.name = ko.observable (""); Self.place = ko.observable (""); }   

MyObservableArray:

  self.Main = ko.observableArray ();   

In between I do something to load data in self.main and I'm sending myself. The controller has the controller with the following types of data:

  The main [0] holds: startDate () - & gt; You may see the name () -> & gt; Array based on "23/10/2014" / "Zone" location () - & gt; "Croatia"   

The possibility

  self The main [9] holds: startDate () - & gt; "29/05/2012" name () - & gt; "Pop" location () - & gt; "USA"   

I am trying to change myself as I want to. Changing the main () and start-up and using the self to send the same controller. > Possible Solution: I can use a different undisclosed array and push all the VM's main but I can do it on self.main Trying to use without me.

If someone can show some light then it is highly appreciated.

What do I get you to face the problem of avoiding / Used to be.

Try it

  "(23/10/2014)". Var arr = [{Date: "(23/10/2014)"}, {date:   "(23/10/2014)"}, {Date: "(23/10/2014)"}, {Date: "(23/10/2014)"}]; Arr.forEach (function (obje) {obj.date = obj.date.replace (/ \ g / "," - ")}) Console.log (arr) // Date field for all items" (23 -10-2014) "will print as    

Comments

Popular posts from this blog

ios - Adding an SKSpriteNode to SKScene from a child SKSpriteNode -

Matlab transpose a table vector -

c# - Textbox not clickable but editable -