There are times when you simply want to throw some JavaScript code up and see how it works.
http://code.tutsplus.com/tutorials/javascript-tools-of-the-trade-jsbin–net-36843
My bookmarks and blogposts regarding Software Development in .NET, C#, Angular, JavaScript, CSS, Html
There are times when you simply want to throw some JavaScript code up and see how it works.
http://code.tutsplus.com/tutorials/javascript-tools-of-the-trade-jsbin–net-36843
string.js is a lightweight (< 4 kb minified and gzipped) JavaScript library for the browser or for Node.js that provides extra String methods.
Why bother with namespaces in javascript?
– You get cleaner and more clear code.
It is more clear what “object” or “task” the function and variables belongs to.
Avoids global function conflicts, my function named Calculate() might conflict with another function inside some js file that has been loaded before my js file.
This is one way of doing it, which I personally prefer:
// CompareProducts Namespace: CompareProducts = {}; //A new function in that namespace: CompareProducts.AddCompareEntry = function () { // CODE INSIDE OF FUNCTION }); //A varible inside the namespace: CompareProducts.myTestVar = "test test"; //A call to the namespaced function: CompareProducts.AddCompareEntry(); //Get variable: alert(CompareProducts.myTestVar);
Another way is this (enclose in sub braces)
var yourNamespace = { foo: function() { }, bar: function() { } }; ... yourNamespace.foo();
Read even more about it here http://thanpol.as/javascript/development-using-namespaces/
You know that annoying thing that happens when you try to click a link or a button on a page and you miss, and accidentally marks some text or html:
Css fix:
body{ -webkit-touch-callout: none; -webkit-user-select: none; -khtml-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; }
via javascript: Disable Text Select – Stack Overflow.
Js IE fix: (probably needed for some versions of Internet Explorer…)
onselectstart = function(){ return false; }
Jquery IE fix:
In jQuery 1.8, this can be done as follows: (function($){ $.fn.disableSelection = function() { return this .attr('unselectable', 'on') .css('user-select', 'none') .on('selectstart', false); }; })(jQuery);
http://stackoverflow.com/questions/2700000/how-to-disable-text-selection-using-jquery
I havent tested these anywhere… yet. But Stack Overflow is usually right.