Sorting An Array of Objects

Example to sort array below using name property: Below will be the methods to sort Asc/ Desc: To call the method:

Querying a stylized list with dynatable

 Example to query a table for a certain value: query from dynamic generated drop down list from the array of objects. var dyna = $j('#serverDetails') .dynatable({ dataset: { records: window.xData, //array of objects perPageDefault: 20 }, features: { paginate: true, sort: true, pushState: false, //must be false if not got error search: false, recordCount: true, …

Continue reading Querying a stylized list with dynatable

How to Use Window.onload() Event

Any DOM manipulation code which depends on the DOM elements located at the head section of the html page, this code will be executed first before the DOM is fully ready. However error may occurs. Therefore, it is required to put the codes inside a callback function which will be fire when the DOM is …

Continue reading How to Use Window.onload() Event

Why does jQuery or a DOM method could not find the element?

As script executed line by line, they are only executed when they are added into the DOM. The order matters. This mean the script cant find the element which written later below as it is not added into the DOM yet. Example: The result for first document.getElementById is null. However, there is value for the …

Continue reading Why does jQuery or a DOM method could not find the element?

How to POST an array of objects with $.ajax

Base on earlier post which I talk about JSON. Here is the application part. Imagine you have an array of objects from client side need post back to server side for processing. JSON.stringify can do the trick of sending the array back to server side. Remember to put it before sending it.    

How to use C# LinQ similar method in JavaScript

Below is a simple example to help understand the usage of the code: var arr = [ {name: 'a', val:1}, {name:'b', val:2}, {name:'c', val:3}, {name:'d', val:4}, {name:'e', val:5}, {name:'f', val:6}, ]; //jquery map var nm = $.map(arr,function(v){ return v.val; }); $("#box").html("jquery map: "+nm); //array map var nm = arr.map(function(v){ return v.val; }); $("#box2").html("array map: "+nm); …

Continue reading How to use C# LinQ similar method in JavaScript

Authorization failure for Ajax request in MVC application

I encounter an ajax request authorization failure and causes bad user experience. I had click on a button which require ajax response in my ASP.net MVC application which already timout. Below is the way to handle it properly without getting any bugs. I have created a OnAuthorizationModule action filter to check on each action to determine …

Continue reading Authorization failure for Ajax request in MVC application