Sort Json by 2 keys.


function sortJSONBy2Keys(a,b,c){var d=function(b,c){return b>c?1:b<c?-1:0};return a.sort(function(a,e){var f=a[b],g=e[b],h=a[c],i=e[c];return d([d(f,g),d(h,i)],[d(g,f),d(i,h)])})}

var sortedJson = sortJSONBy2Keys(originalJson,'key1','key2');

 

Example: https://jsfiddle.net/1934z53s/

 

Advertisements

Review: Ajax POST to C# WebMethod

[WebMethod]
public static void testingWebMethod(Object dataTest)
{
Debug.WriteLine(dataTest);

Debug.WriteLine(dataTest);
}

 

var sendThisData = JSON.stringify({
dataTest: [{ "name": "foo" }]
});
$.ajax({
type: "POST",
url: "page.aspx/testingWebMethod",
data: sendThisData,
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function () {
},
error: function () {
alert("Something went wrong.");
}
});

Differences in syntax between AngularJS, Angular2, React, and Vue.js

(by AXDS)

Here’s some examples showing the differences in syntax between AngularJS, Angular2, React, and Vue.js  🙂

All of these examples are doing pretty much the same thing:

AngularJS: https://jsfiddle.net/g7bk9Lk5/

Angular2: https://jsfiddle.net/pt5ox9mp/

React: https://jsfiddle.net/ma9bg0gt/

Vue.js: https://jsfiddle.net/2ojtoaxx/

 

 

 

Vue.Js Components

Testing how components work in Vue.Js

Simple Example: https://jsfiddle.net/4v6khn77/

var Testing_Component = Vue.extend({
template: 'Hello World'
});

var mainViewModel = new Vue({
el: '#myApp',
components: {
'testing-component': Testing_Component
}
});

Component inside list Example: https://jsfiddle.net/3d91z7pe/


var Person_Component = Vue.extend({
template: '
	<li style="color:{{ color }}">{{ foreName }} {{ lastName }}</li>
'
});

var listOfPeople = [{
foreName: 'Wade',
lastName: 'Wilson',
color: 'red'
}, {
foreName: 'Peter',
lastName: 'Parker',
color: 'blue'
}];

var mainViewModel = new Vue({
el: '#myApp',
data: {
peopleList: listOfPeople
},
components: {
'person-component': Person_Component
},
template: '
<ul><person-component v-repeat="peopleList"></person-component></ul>
'
});