Showing posts with label javascript. Show all posts
Showing posts with label javascript. Show all posts

Wednesday, 4 September 2013

Where do you need to use javascript MV* framework

I like following while I was reading an article on javascript frameworks: I thought it is worth repeating:

So, where will you likely need an MV* framework and where won’t you?

If you’re writing an application that will likely only be communicating with an API or back-end data service, where much of the heavy lifting for viewing or manipulating that data will be occurring in the browser, you may find a JavaScript MV* framework useful.

Good examples of applications that fall into this category are GMail and Google Docs. These applications typically download a single payload containing all the scripts, stylesheets and markup users need for common tasks and then perform a lot of additional behavior in the background. It’s trivial to switch between reading an email or document to writing one and you don’t need to ask the application to render the whole page again at all.

If, however, you’re building an application that still relies on the server for most of the heavy-lifting of Views/pages and you’re just using a little JavaScript or jQuery to make things a little more interactive, an MV framework may be overkill. There certainly are complex Web applications where the partial rendering of views can* be coupled with a single-page application effectively, but for everything else, you may find yourself better sticking to a simpler setup.

Tuesday, 29 June 2010

HTML5 and touch phone devices

Here is the first (I think) framework for Mobile phone (touch) devices, I need to explore more on this and will post in detail soon.

http://www.sencha.com/

Sencha Touch allows your web apps to look and feel like native apps. Beautiful user interface components and rich data management, all powered by the latest HTML5 and CSS3 web standards and ready for Android and Apple iOS devices. Keep them web-based or wrap them for distribution on mobile app stores

Monday, 31 May 2010

Few Handy Javascript functions for HTML forms

Here are few handy javascript function, which I use on day today basis in my Web development:

// Returns string after trimming spaces from both sides
function AllTrim(str)
{
str = LTrim(str);
str = RTrim(str);
return str;
}
//Returns string after trimming spaces from left side
function LTrim(str)
{
return str.replace(/^\s+/g,'');
}
//Returns string after trimming spaces from right side
function RTrim(str)
{
return str.replace(/\s+$/g,'');
}
// validates email form field, if you pass true, it checks for empty field as well
function checkEmail(str, required)
{
regexPattern = /^[a-zA-Z_0-9-]+(\.[a-zA-Z_0-9-]+)*@([a-zA-Z_0-9-]+\.)+[a-zA-Z]{2,7}$/;
str = AllTrim(str);
if (required == 'undefined' || required )
{
if( str.length == 0 )
{
return false;
}
}
else
{
if( str.length == 0 )
{
return true;
}
}
return regexPattern.test(str);
}
// returns selected radio button value from a group of radio buttons in a form
function getSelectedRadioValue(formObj, obj)
{
var selected_radio_val = '';
for (var i=0; i < document[formObj][obj].length; i++)
{
if (document[formObj][obj][i].checked)
{
selected_radio_val = document[formObj][obj][i].value;
break;
}
}
return selected_radio_val;
}

Thursday, 5 November 2009

Java script trim function

I have used this trick in different places and sometimes when I need it again, I always forget, tahts why I am putting it here:

function AllTrim(str) // call this function if you want to remove spaces from both sides
{
str = LTrim(str);
str = RTrim(str);
return str;
}
function LTrim(str) // this function removes spaces from left
{
return str.replace(/^\s+/g,'');
}
function RTrim(str) // this function removes spaces from right
{
return str.replace(/\s+$/g,'');
}