Skip to content

dogstyle/example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 

Repository files navigation

example

The dog style, or dog "pattern" is a practical way of writing JavaScript (EcmaScript) that affords clean modular coding practices that make it easy for others to read and adapt. This style of writing code takes advantage of Javascript's scoping, and allows you to develop code in tandem with Chrome's console to rapidly build pages in a testable way.

function SomeModule($obj, options) {

  options = options || { }
  options.someOption = options.someOption || 42

  var dog = {
    options : options
    , $obj : $obj
    , $someThingCool : undefined
  }
  
  function events() {
    dog.$someThingCool.click(function() {
      console.log("you just clicked me")
    })
  }
  
  function init() {
    dog.$someThingCool = $obj.find(".somethingCool")
  }
  
  init()
  
  return dog
}


$(document).ready(function() {
  someModule = SomeModule($("#myBox"), {  someOption : 21  })
})

About

example page

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published