JSFiddle

  • Default Parameter Assignment

    Efficient way of assigning default values in functions

    // global default values, and other parameters to pass into MyFunct
    var myDefaultObj = {id:987},
        myP1 = ["abc",123],
        myP2 = {id:"foo ...
  • Asynchronous Dialogs with Noty

    Promise implementation and publish/subscribe pattern in javascript

    <h1>Asynchronous Dialogs with Noty</h1>
    <p>One of the problems with going from the LotusScript ui programming to Javascript programming, particularly with ...</p>
  • Closure Example

    How closures hide stuff for you

    $(document).ready(function(){
        $("#btnClosure").click(function(){
    var personFactory = function(fn, ln,age){
    	// this function has a local variable named _person ...
  • Pure CSS rating widget

    No-Library (pure JS), HTML, CSS, JavaScript

    <!-- kudos to Lea Verou http://jsfiddle.net/user/leaverou/fiddles/ -->
    <h3>Employee Rating</h3>
    <p>Overall this employee's star rating is:
    <fieldset class="rating">
        <legend>Please rate:</legend>
        <input type="radio" id="star5" name="rating" value="5" /><label for="star5" title="Rocks!">5 stars</label>
        <input type="radio" id="star4" name="rating" value="4" /><label for="star4" title="Pretty good">4 stars</label>
        <input type="radio" id="star3" name="rating" value="3" /><label for="star3" title="Meh">3 stars</label>
        <input type="radio" id="star2" name="rating" value="2" /><label for="star2" title="Not very good">2 stars</label>
        <input type="radio" id="star1" name="rating" value="1" /><label for="star1" title="Sucks big time">1 ...</label></fieldset></p></!-->
  • Ajax and JSON with jQuery

    Gets JSON data via Ajax server call

    $(document).ready(function () {
    
        $("#btnGetJSON").click(function (e) {
            e.preventDefault();
    
            $.getJSON("https://gist.githubusercontent.com/billwheaton1715/0bbb615afb93143b1dcc/raw/54e1393300e39a084fd129143eef002bd331f7cc/jsonfile", function ...
  • Classes Constructors and Prototypes

    How to make classes in javascript

    var mySmallObject = {
        name: "Small Thing",
        sayName: function () {
            alert(this.name);
        }
    };
    
    // this is the polar coordinate class it takes the distance ...
  • Nested Functions as Closures Neatened

    jQuery 2.1.3, HTML, CSS, JavaScript

    // In javascript, functions are data just like any other value.  Array, Object, String, RegExp, Date etc., and primitive types, boolean ...
  • Nested Functions as Closures

    No-Library (pure JS), HTML, CSS, JavaScript

    // In javascript, functions are data just like any other value.  Array, Object, String, RegExp, Date etc., and primitive types, boolean ...
  • Anonymous Function Example

    This is an example of an anonymous function that is called as soon as it is defined

    var localVariable = "This is defined in the default global namespace";
    
    // example of an anonymous, imediately invoked function
    (function () { //N.B ...
  • tag test

    display some spans and some divs with css

    <div id='test'>Hello World!</div>
    <br/>
    <div id="view1">
        <div id="view1:nestedDiv">this is my<span id="view1:nestedDiv:mySpan" class="gaudy">span</span> with some text before and after it</div>
    </div>
    <br/>
    <div id="view2">
        <div id="view2:nestedDiv" class="gaudy">this is my<span id="view2:nestedDiv:mySpan" class="lookslikeblock">span</span> with some text ...</div></div></br/></br/>
  • Template test

    shows the results of a template after it is evaluated

    $(document).ready(function(){
    
        $("#but").click(function(e){
            e.preventDefault();
            var txt = (function(){ var t = _.template($('#myTmpt').html()); return t ...