Sort array by date gives unexpected results

short answer You should return the difference between the two dates, not a boolean: // sort the data by date using moment.js seriesRawDataArray.sort(function (left, right) { return moment.utc(left.timeStamp).diff(moment.utc(right.timeStamp)) }); why Array.prototype.sort expects a negative, zero, or positive value to be returned. Generally, you’ll write a sort function like this: yourArray.sort(function (a, b) { if (a … Read more

How to data-bind the ‘class’ or ‘id’ attribute of a div, while using containerless control flow?

You can use the css binding. It can be used two ways. Either with a dynamic class (or list of classes): <li data-bind=”css: name”></li> or with individual classes bound against truthy/falsy values to indicate whether that are should be added/removed from the element: <li data-bind=”css: { classOne: hasClassOne, classTwo: hasClassTwo }”></li>

How to unsubscribe the subscribed function in knockout?

Store results of call to subscriptions in a variable (or, in your case, in an array). When you want to unsubscribe, simply call dispose on each subscription. Fully described here – http://knockoutjs.com/documentation/observables.html Your code will look like this: //store subscriptions in array var subscriptions = []; for ( var i in myViewModel ) { var … Read more

What is the best way of cloning/copying an observablearray in knockoutJS?

To clone an observableArray you would want to do: var viewModel = { array1: ko.observableArray([“one”, “two”]), array2: ko.observableArray() }; viewModel.clone = function() { viewModel.array1(viewModel.array2.slice(0)); }; If you want to just do a copy, then you would do: viewModel.array1(viewModel.array2()); The problem with the second example is that the underlying array is the same, so pushing to … Read more

Close Bootstrap Dropdown after link click

Give your links a class (e.g. download): <a href=”#” class=”download” data-bind=”disable: noResults()…. And your dropdown an id (e.g. dlDropDown): <button class=”btn dropdown-toggle” id=”dlDropDown” data-toggle=”dropdown” data-bind=”enable: !noResults()”> And then add the following event handler: $(“a.download”).click(function() { $(“#dlDropDown”).dropdown(“toggle”); });

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)