Tag Archives: jquery

setting a html5 data attribute with jquery

Abstract I have a single bootstrap modal, which is called from different places, and so the modal contains some data-* attributes I want to set before showing it. Just using the .data() offered by jquery does not work. Detailed example Suppose you have mark-up like this: <div data-some-important-value=”123″> Asking the value is quite easy: $(‘[data-some-important-value]‘).data(‘some-important-value’) […]

rails3 doing cross-browser json

I have two rails applications that communicate together. In the first application i have the following method in my controller: which, if go to the url in my browser, nicely shows my the JSON. Seems ok. However, if i call this through jQuery, from my second application, using the following: then the right url is […]

handling ajax callbacks in rails3 using jquery

Previously, in rails 2.3.8 i used the prototype-helpers link_to_remote and form_remote_for (amongst others). These had the option to add callbacks as follows: (an example from the documentation). This example would, upon success update the html-element with class “cart”, and upon failure the class “error”. The possible callbacks were: :loading: Called when the remote document is […]

rails 3 and haml and unobtrusive javascript

I have created a Rails3 application, started with Haml/Sass and finding it awesome. I am also trying to do unobtrusive javascript. Before, in Rails 2.3, I would have expected a remote-form to have an :update attribute, where you could specify a selector where the response of the remote method would be rendered. Now it needs […]

starting a new rails3 site using rspec2 and jquery

With Rails3 i can create a project fully cut to my needs. I will write it down here, just so i remember it well and hopefully it will help some of you too. In my projects, i want to use haml, rspec2, factory-girl, jquery, … We need a few steps to complete this. Create the […]

using content_for jquery on document ready

In my Rails application i use a generic application.rhtml for all my pages. Amongst others, this code contains some jQuery code to manipulate my page The things i do in my document ready callback is simple: remove the alt attribute everywhere, so my tooltips will work on my links containing images, and if there is […]

jquery validation only one field in a group required

I am using the jQuery validate plugin which is awesome for straightforward form validation. What i especially like is that it offers the user a better user experience, because there is no need for the round-trip to the server. I still need to do the validation on the server-side (rails) as well. I guess there […]