coffeescript.org

The Javascript in operator does what Hash#has_key? does in Ruby: Return whether an object has a property. However, Coffeescript has its own in operator that checks for array...

...inclusion. To check whether an object has a property, use of: Javascript 'name' in {name: 'Horst'} # => true Coffeescript # wrong 'name' in {name: 'Horst'} # => false # correct 'name' of {name: 'Horst'} # => true...

...User-definable order of items Complicated item elements with super-custom CSS and other Javascript functionality Items that can be both leaves and containers of other items has_ancestry on...

...ended up using only draggable and reimplement something like droppable in ~120 lines of Javascript. There is some drag'n'drop support in Capybara/Selenium nodes, but again it's not...

rails-assets.org

Automatically builds gems from Bower packages (currently 1700 gems available). Packaged Javascript files are then automatically available in your asset pipeline manifests. Why we're not using it

...choice to use bower-rails instead. While we believe Rubygems/Bundler to be superior to Javascript package managers, we wanted to use something with enough community momentum behind it that it...

benmccormick.org

...of techniques that were best practices with ES5, but have better alternatives in modern JavaScript. Best practices don’t last forever. This is especially true when a field is changing...

...fast, and JavaScript development has changed a lot over the past 10 years. The old best practices go stale, and new ones take their place. Here are 5 JavaScript best...

...t been written down in this deck before, here it goes: When working with JavaScript Event objects, the DOM element that triggered the event is attached to them. [1]

Promises are the new way™ to express "Do this, and once you're done, do that". In contrast to callbacks...

There is no way to do it. This behavior is by design. You lose.

...non-breaking spaces or hyphens of various lengths. For this, use the ways below. Javascript, Coffeescript Use the \u escape sequence: note = '\u266A' You can use Unicode escape sequences in...

...opacity': 1, 'margin-top': 0 }, { duration: 500 }); } The animation is implemented using setInterval and Javascript. This works great, but it's not as smooth as a CSS transition. Fortunately the...

...as a drop-in replacement for animate, but animate using CSS transitions instead of Javascript. This gives you a much higher framerate. If Transit has too many bells and whistles...

Then I should see an error These step definitions will not work for @javascript scenarios using the selenium web-driver @allow-rescue @javascript Scenario: Accessing the admin area requires...

Getting a regular expression from a string in JavaScript is quite simple: new RegExp('Hello Universe'); # => /Hello Universe/ You can also use special characters: new RegExp('^(\\d+) users') # => /^(\d+) users...

When you need to check a value for presence, don't rely on JavaScript since it considers 0 or "0" false. Also don't rely on LoDash's _.isEmpty:

Having a unique selector for an element is useful to later select it from JavaScript or to update a fragment with an Unpoly. Haml lets you use square brackets ([]) to...

javascriptcompressor.com

Compress and obfuscate Javascript code online completely free using this compressor...

Some modern Javascript APIs return iterators instead of arrays. In plain Javascript you can loop through an iterator using for...of: var iterator = ...; for (var value of iterator) { console.log(value...

...someone reloads a form by pressing enter/return in the URL field, or by opening JavaScript links incorrectly. The attached initializer provides a default way to deal with this.

validatious.org

validate( "email".is("required").andIsAn("email") );

Attached (see below) is some code to allow using unobtrusive JavaScript on pages fetched with an AJAX call. After you included it, you now do not use the usual

...unobtrusive() to register new element activation callbacks $.unobtrusive = function(callback) { $(document).on('activate-unobtrusive-javascript', function(event, root) { $(root).each(callback); }); } // Define a function for all jQuery collections to manually...

If you manipulate the DOM with JavaScript and your page contains nested elements with position: relative, chances are Internet Explorer 7 will not properly move to the right position.

...nest. This is often impossible, though. Force the correct redrawing of the elements using JavaScript. Adding a bogus class ($(element).addClass('touch')) seems to suffice. Try to give the offending...

Use the click method on the DOM element: let link = document.querySelector('a') link.click()

You can say: $(element).is(':visible') and $(element).is(':hidden') jQuery considers an element to be visible if it...

jashkenas.github.com

Imagine all the syntactical delights of Ruby and Haml for your JavaScript. You write in a nice language, but get normal JavaScript at runtime. All whilst having full access to...

...3rd-party JavaScript libraries (jQuery, PrototypeJS), debugging support (it becomes pure, readable JavaScript), existing support from test suites (it’s normal JavaScript) and growing support from various text editors (TextMate...

getfirebug.com

...a Firefox extension but there is also a "Lite" version which runs purely off JavaScript. Though all major browsers offer inspection tools you may like the Firebug style. Also, for...

Get the bookmarklet over at http://getfirebug.com/firebuglite#Stable. It usually loads the JavaScript code from a remote server but you can also download it to have it run...

gist.github.com

The NestedHash class allows you to read and write hashes of any depth. Examples: hash = {} NestedHash.write hash, 'a', 'b', 'c...