Kendo UI Editor – A FreeTextBox Replacement

The Kendo UI Editor is simple to use and easy to implement. I found it to be a great FreeTextBox replacement, the editor that I’ve used in the past.

Here are a few reasons:

  • Kendo editor is configured client-side in the JavaScript
  • Kendo editor doesn’t rely on a server side control on the page, allows more control of what’s rendered
  • No need to recompile when a configuration change is made to the Kendo editor

Kendo UI Editor (JSFiddle)

Cache JQuery Selectors To Improve Performance

JQuery logo text

An easy way to improve jQuery performance is to cache reused jQuery selectors. This prevents jQuery from having to search the entire DOM for each instance the selector is being used.

For example, instead of this:

$(document).ready(function() {
	$('#FName').html('My First Name');
	$("#changeName").click(function() {
		$('#FName').html('My Other First Name');
	});
});

Try this:

$(document).ready(function() {
	var fName = $('#FName');
	fName.html('My First Name');
	$("#changeName").click(function() {
		fName.html('My Other First Name');
	});
});

By the way, jQuery id selector maps to the native JavaScript function document.getElementById().

Short Experiment

I still prefer document.getElementById() over jQuery ID selector, when possible, see the results below:

Cache JQuery Selectors (JSFiddle)

Values considered false in JavaScript – false, null, undefined, NaN

Unofficial JavaScript logo
The false values in JavaScript:

  • false
  • null
  • undefined
  • The empty string ”
  • The number 0
  • The number NaN (result of an operation that cannot produce a normal result)

False JavaScript Values (JSFiddle)

All other values evaluate to true, including true, the string ‘false’, and all objects.

Another tidbit about NaN is that it is not equal to any value, including itself.

Simple way to understand the difference between JavaScript, JScript, & ECMAScript

JavaScript is a prototype-based scripting language that is dynamic, weakly typed and was formalized in the ECMAScript language standard.

JScript is the Microsoft implementation of the ECMA 262 language specification (Source).

ECMAScript is the scripting language standardized by Ecma International and is widely used for client-side scripting on the web.

Here’s a good explanation.

Boolean object in JavaScript

The Boolean object represents two values either “true” or “false”.

new Boolean(value);

If value parameter is omitted, 0, -0, null, false, NaN, undefined, or the empty string (“”), the object has an initial value of false due to automatic type coercion.

Here’s a simple test for the JavaScript boolean object, here’s the HTML anchor tag I used to call a function:

<a href=”http://www.melvinswebstuff.com” onclick=”GetBoolean(‘true’); return false;”>Get Boolean</a>

Here’s the JavaScript function:

function GetBoolean(bBool){
	//Create a boolean object
	var myBoolean = new Boolean();
	myBoolean = true;
	
	if(myBoolean) alert('myBoolean = ' + myBoolean);
	
	if(myBoolean) alert('bBool = ' + bBool);
	
	if(bBool == myBoolean){
		alert('bBool == myBoolean');
	} else {
		alert('bBool <> myBoolean');
	}
	
}

Inline IF’ Statement

C#

string s; 
s = (true ? "True" : "False"); //s will be "True"

VB.NET

Dim s As String
s = If(True, "True", "False") 's will be "True"
'In the following you cannot rely on a particular function 
'not being called if the other argument is selected by Expression
'(notice IIf vs. If)
s = IIf(True, "True", "False") 's will be "True"

JavaScript

var s = (true) ? 'True' : 'False'; //s will be "True"