...best cost-benefit ratio. (Know that this does not detect touch devices, but browsers.) Javascript var isTouchDevice = 'ontouchstart' in window Coffeescript isTouchDevice = 'ontouchstart' of window On the difference between the...
...Javascript and the Coffeescript version, see Beware: Coffeescript "in" is not the Javascript "in...
I had to deal with JavaScript Undefined Error while accessing a specific CKEditor instance to fill in text. Ensure everything is loaded with patiently do page.execute_script("return isCkeditorLoaded('#{selector...
...selector}');").should be_true end html.gsub!(/\n+/, "") # otherwise: unterminated string literal (Selenium::WebDriver::Error::JavascriptError) page.execute_script("CKEDITOR.instances['#{selector}'].setData('#{html}');") end The snippet for JavaScript: function isCkeditorLoaded(instance_selector...
...you want to overwrite inherited methods but call the parent's implementation, too. In JavaScript, there is no simple "super" method like in Ruby -- so here is how to do...
...BaseClass to run as well -- and if you want to call a method in JavaScript, you need to do exactly that. Backbone offers a shortcut that is not too ugly...
...page, and have Selenium click it: path = "/your/path/here" id = "helper_#{SecureRandom.hex(8)}" execute_script <<-JAVASCRIPT var $helper = $(' ').attr({ href: #{path.to_json}, id: #{id.to_json}, target: '_blank' }); $helper.prependTo('body').text('click...
...me').css({ zIndex: 9999, position: 'absolute' }); setTimeout(function() { $helper.remove() }, 1000); JAVASCRIPT find("##{id}").click Note that the link tag is removed after 1 second. You may or may not want...
You can also tell Unpoly to treat that one link as a vanilla Javascript link...
...page may load without assets. The dev server will detect any changes to your JavaScript and CSS and re-compile automatically. When it is done automatically any browser window showing...
...have a dev server running and call any helper that accesses asset paths (e.g. javascript_pack_tag or image_tag), Rails will compile your entire assets within its process before...
end Short explanation: asset_host is used for links to stylesheets and javascripts asset_host belongs to ActionController::Base -- changes are persistent and will not be reset after...
...because we cannot yield out of define_method module InstanceMethods private # Force URLs for JavaScript and Stylesheet links def assets_have_urls old_asset_host = asset_host self.asset_host = HOST...
You are not using javascript tests The file is served from a public folder (not via controller) Problem description If you deliver files from a public folder it might...
...response with content-type "..." Outline How to test file downloads with tests that need javascript. Public served Look at the link of the url and check if this file exists...
...also namespaces files compiled files inside a pack CSS files are stored inside css, JavaScripts inside js and images inside media If you namespaced your pack's contents like /your-pack-name/images...
...commit messages, add a new link "Commit" to your bookmarks and use the following Javascript as the link URL: javascript:(function() { let storyTitles = []; let stories = Array.from(document.querySelectorAll('.story[data-selected...
...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:
...making a vanilla form submission to a hidden and try to wrap a nice Javascript API around this. I found it really hard to make this work reliably.
...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...
...a great enhancement when you want users to supply some kind of code (HTML, JavaScript, Ruby, etc). It offers syntax highlighting and some neat features like auto-indenting.
...some utility functions for DOM manipulation and traversal in the up.element module. Further reading JavaScript without jQuery (presentation from...
...openTasks = $.find('.task.open', container); Note that Sizzle returns vanilla DOM nodes in a vanilla Javascript array. It does not return jQuery collections...
scope.paragraphs = _.map paragraphs, (lines) -> lines.split('\n') Also see simple_format helper for Javascript...
...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...
...mind that the above examples use jQuery. Tweak accordingly if you are using another JavaScript framework...
...some kind of pre-processing. You could probably also hack together a solution in JavaScript which downloads the background image file, rewrites the XML string and generates a data: URI...
...use Semantic Versioning's naming convention. If your library has both a Ruby and JavaScript component and you want to use the same version constant for both, you can use...
...this, you simply cannot clone instances of Coffeescript instances as you would clone other Javascript hashes. If you need cloning, you would probably need to implement a clone() method in...
...or close the dialog. The easiest way to interact with the editor is via javascript postMessages. To abort the dialog a post message on click with an event listener like...
= form.file_field :add_images, class: 'hidden', multiple: true Add Images = gallery_form.submit Javascript Now to the dynamic part. I built it with an Unpoly compiler, but the code...