Posts

Showing posts with the label jquerytools

Bootstrap (by Twitter) loading in page content for Popovers

Bootstrap is a nice get started HTML/CSS/JS interface toolkit. At $work our newest design has been based on it and many of its components. One of the challenges I've run into with the Popover element is generating in attribute content for complex elements. The basic context is: <a id="mypopover" href="#" data-content="stuff to display"> Label </a> The popover gets the body from the data-content attribute. The other option that doesn't appear to be documented is using a function set in the options. $('#mypopover').popover({ // other options here content: function(ele) { return $('#popover-content').html(); } }); This will load the html content from element '#popover-content' when calling 'show' on popover. Note : If trigger element still has a data-content element, even if its empty, the content function will not be called by method. My biggest issue still with Bootstrap tools is t...

jQuery - "getting" chains

I've been using jQuery for quite a while now. I really like its interface, often it feels very Perlish to me. But in the past I've struggle when trying to process or access parts of a single element returned by a selector. Most of the time, I really want to grab it with an array index, e.g. $('.special-sauce')[0].href (just some rough example). But that always felt wrong, against the jQuery way, like i was an outsider. Esp when its so natural do things like: $('a.special-sauce').click( function() { // do something } ); I've tried to use the first() method to get a single element but that returns an array too. But I finally got how to use it today... We are using jQuery Tools for overlays and some other actions. I wanted to retrieve the href attribute for the trigger object (the one that was clicked to open the overlay (aka lightbox). I tried the wrong feeling: this.getTrigger()[0].href and had the moment of clarity that said "that really mean...