...openTasks = $.find('.task.open', container); Note that Sizzle returns vanilla DOM nodes in a vanilla Javascript array. It does not return jQuery collections...

...will break after modifying the collection like above. The following solution works. It uses JavaScript methods which modify the object in place, thus keeping any extra attributes: var index = element.indexOf...

angular-tips.com

Service just like Factory, but: instead of a funciton, it receives a Javascript class / a constructor function as argument simplest service type, but also least flexible Value

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...

...mind that the above examples use jQuery. Tweak accordingly if you are using another JavaScript framework...

...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.

makandra dev
github.com

...flaky end-to-end tests: This Ruby gem synchronizes Capybara commands with client-side JavaScript and AJAX requests. This greatly improves the stability of a full-stack integration test suite...

...Another concise way to write the statement is this: console.log({ foo, bar }); This uses Javascript's new destructuring syntax and is actually shorthand for: console.log({ foo: foo, bar: bar });

behavior: url(/PIE.htc); background: white; } li.active .content { background: red; } If you now use JavaScript to add the class .active to another li, the contained .content (whose background should have...

...a nice data attribute to the form fields, and look for that in your JavaScript code: document.on('change', '[data-requires-update]', updateThings); If you are interested in the element that...

makandra dev
css-tricks.com

...re already using lazysizes, you can use its object-fit polyfill! Usage In your Javascript manifest, require them like this: #= require plugins/object-fit/ls.object-fit #= require lazysizes Now use the mixin below to...

...a correct window. [1] as in: a real browser window, maybe via window.open in JavaScript

...this useful when creating responsive designs that work well on small screens. The attached Javascript gives a container different CSS classes (single_line or multiple_lines) depending on whether its...

...not necessarily a link or button, but could be any HTML element with a Javascript event binding. The easiest way to get this step is to use Spreewald. If you...

...aka least harmful) submit element before others. NB: If you submit a form via JavaScript none of the buttons' attributes will be submitted...

developers.google.com

...so you can both use up the entire quota. Note that the Google Maps Javascript API (the one that draws maps on the screen) has a different quota policy. Here...

...for the given label, then checks if that field is hidden via CSS (or Javascript). It is not currently tested if the label is visible or hidden. For this see...

You can include files from app/assets or from the public folder with javascript_include_tag. The subtle difference that tells rails how to build the path correctly is a single...

...slash at the beginning of the path: <%= javascript_include_tag('ckeditor/config') %> # for assets/ckeditor/config.js <%= javascript_include_tag('/ckeditor/ckeditor') %> # for public/ckeditor/ckeditor.js This also applies to stylesheet_link_tag. Note that when you...

...order to navigate through the browser history. you can manipulate the window.history object via javascript like follows: When /^I go back in the browser history$/ do page.evaluate_script('window.history.back()')

stackoverflow.com

...menu for copying and pasting will appear. This can confuse unexperienced users. Use the Javascript hack below to disable text selection on mobile devices: // Deactivating distracting Text Selection:

makandracards.com

...t reliably work in Selenium features. I overhauled the entire step so it uses Javascript to detect visibility in Selenium. The step has support for jQuery and Prototype projects, so...

...this, test for the right environment and place the JS-code afterwards: - if Rails.env.production? :javascript var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-XXXXXXXX-X']); _gaq.push(['_trackPageview...

code-experience.com

React.js is a relatively new Javascript templating engine that has two-way-bindings like AngularJS or Batman. The interesting idea here is that React keeps a virtual copy of the...