Pivotal Labs

Main menu

Skip to primary content
Skip to secondary content
  • About
  • Case Studies
  • Team
    • Executives
    • Locations
      • San Francisco (HQ)
      • Boston
      • Boulder
      • Denver
      • London
      • Los Angeles
      • New York
  • Community
    • Blogs
    • Tech Talks
    • Events
  • Careers
    • Lifestyle
    • Principles & Practices
    • Benefits
    • FAQ
    • Apply
  • Contact
    • Press Room
    • Press Releases
    • In The News
    • Press Kit
  • All
  • Labs
  • Standup
  • Tracker
Robbie Clutton

Why we should care about not using anchor tags for page interactions

Robbie Clutton
Thursday, January 19, 2012

I was pairing with Adam today when we had a chance to write a little Javascript. This was an interaction that changed state in the DOM without changing the page location, and we initially used an anchor element. I remembered a spectacular rant by Dan Webb about why anchors shouldn’t be used in this way. I couldn’t quite find the tweets I was looking for, so I asked.

[View the conversation between Dan Webb and myself here on Storify]

Essentially the gist is “if you don’t have a URI, then don’t use the anchor tag”. That means not using markup like

  <a href="#">click</a>

I can hear Matt Andrews telling me to put a javascript void call in the href, and although I understand the point that it won’t do anything if Javascript isn’t enabled on the page whereas using ‘#’ would, and that it states its intentions through calling Javascript directly, I now think we can do a little better. So we shouldn’t do this either:

  <a href="javascript:void(0)">click</a>

I did the first pass of a refactor and started to use a span element before Berger pointed out that that was probably just as non-semantic as the anchor element. I had to concede the point.

For our case, the best option was an input element with type button. That summed up the best interaction for our use case; manipulating the DOM on a user action, without referencing another resource or an anchored point within the current document.

The thing is, it’s a small change and there are so many examples on the web where the href=# pattern is used. It does work, so why bother changing it? Well yes, while it might work, this isn’t the purpose of an anchor tag. There are other elements that will work just as well for you and make semantic sense. If we do that, then we can all make Dan a little happier.

  • 0 Shares
  • Share on Facebook
  • Share on Twitter
Glenn Jahnke

Standup 1/9/2012

Glenn Jahnke
Monday, January 9, 2012

Helps

CCMenu + Hudson w/o Basic Auth

“Has anyone figured out how to use CCMenu with Hudson and not have Basic Auth?”

Hudson has its own authorization mechanism, unlike Basic Auth, so it can’t be used with nice desktop tools like CCMenu which shows the red/green square in your system tray.

Consider using Jenkins.

Using Symlinks with Dropbox

Using the Linux Dropbox client seems to allow symlinks to be uploaded, but they will not behave as expect anywhere else. Someone was trying to have a “latest” folder point to the latest versioned folder.

The recommendation was just to have two copies of the files as a workaround.

Interestings

Rails Bridge Outreach for Women Workshop has space

Looking to learn Rails? There’s a great meetup to get you up and running. As of this writing there is still space available. Come check the event out.

Yammer Javascript Meetup on Tuesday

Yammer will be hosting a Javascript meetup, expect the usual snacks and beer, and good talks about our favorite client-side language.

  • 0 Shares
  • Share on Facebook
  • Share on Twitter
Glenn Jahnke

Polyglot Factorial

Glenn Jahnke
Tuesday, November 15, 2011

Someone on Hacker News mentioned the number of orderings of a deck of cards. I took up the challenge in some of my favorite and not so favorite languages, I’ll let you guess :).

Ruby

ruby-1.9.2-p180> (1..52).inject{|a,b|a*b}
=>
80658175170943878571660636856403766975289505440883277824000000000000

Scala

scala> BigInt(1).to(BigInt(52)).toList.foldLeft(BigInt(1))((a,b) => a*b)
res23: scala.math.BigInt =>
80658175170943878571660636856403766975289505440883277824000000000000

Haskell

Prelude> foldl1 (x -> y -> x*y) [1..52]
80658175170943878571660636856403766975289505440883277824000000000000

CoffeeScript

coffee> [1..52].reduce (a,b) -> a*b

8.065817517094388e+67

Java

Non-existent REPL>
import java.math.*;
public class Factorial {
public static void main(String[] args) {
BigInteger result = BigInteger.ONE;
BigInteger fiftyTwo = new BigInteger(”52″);
for(BigInteger i = BigInteger.ONE; i.compareTo(fiftyTwo) <= 0; i = i.add(BigInteger.ONE)) {
result = result.multiply(i);
}
System.out.println(result);
}
}

$ java Factorial
80658175170943878571660636856403766975289505440883277824000000000000

** I could have used the product function in most of those examples, but I wanted to play with foldL ;)

  • 0 Shares
  • Share on Facebook
  • Share on Twitter
Mike Gehard

Waiting for jQuery Ajax calls to finish in Cucumber

Mike Gehard
Tuesday, May 3, 2011

You may be asking yourself why you’d want to do this in the first place. Well here’s why I would want to do it.

We had some Webdriver based Cucumber tests that passed fine locally but kept failing on our CI box. Our CI box is a bit underpowered at the moment so I thought what might be happening is that our tests weren’t waiting long enough for the Ajaxy stuff to happen because the Ajax responses were taking a long time.

After some poking around in the source code of jQuery, I found the $.active property. This property keeps track of the number of active Ajax requests that are going on and I thought this might help us out.

What I came up with was this gist:

I added this step right after my Cucumber step that caused the Ajax call so that Cucumber would wait to move on until I knew that everything was done.

This step solved our CI failures and all was good in our test suite again.

  • 0 Shares
  • Share on Facebook
  • Share on Twitter
Glenn Jahnke

Standup 2011.04.14 – Bustin' Caches, Pow, and Trajectory

Glenn Jahnke
Thursday, April 14, 2011

Helps

Busting JS Caches Better

How do I bust Javascript caches better? Changing the url params doesn’t always work?

The most consistent way to bust Javascript caches is to change the path to it. Sometimes transparent proxies and some browsers won’t be busted otherwise.

Busting Chrome JS Cache when running Jasmine Fixtures

Chrome is cache Jasmine fixtures and Firefox is just too slow.

No great solution. Chrome typically runs tests so fast that just mashing the refresh until your test output changes seems to work for some.

Interestings

Trajectory

Trajectory is a new product out by Thoughtbot which has been described as a cross between Tracker and Basecamp.

Pow

37Signals has come out with a native Mac app called POW. Here’s a snippet from the Readme:

Pow is a zero-configuration Rack server for Mac OS X. It makes developing Rails and Rack applications as frictionless as possible. You can install it in ten seconds and have your first app up and running in under a minute. No mucking around with /etc/hosts, no compiling Apache modules, no editing configuration files or installing preference panes. And running multiple apps with multiple versions of Ruby is trivial.

A fellow Pivot also mentioned that it makes running multiple apps on the same port, and having sub-domains easier.

Firefox cacheing

There is an option in Firefox to remember the last opened tabs so when you return to your browser, it will restore your last viewed websites.

This has the unfortunate side-effect of not deleting cookies despite the opposing setting for deleting all cookies upon session exit.

  • 0 Shares
  • Share on Facebook
  • Share on Twitter
Pivotal Labs

Standup 1/21/2011: Rubymine helpful hint of the day

Pivotal Labs
Friday, January 21, 2011

Ask for Help

“What do you recommend for Devise user invitations?”

Interesting Things

  • Did you know that Rubymine can search files found with a previous search? Do cmd-shift-f and do a search. Do cmd-shift-f again. In the dialog, select ‘custom’. In the drop down list is ‘Files in Previous Search Result’
  • Former Pivot Alex Chaffee is teaching a javascript class, and there are still a few openings.
  • 0 Shares
  • Share on Facebook
  • Share on Twitter
Pivotal Labs

Standup 1/19/2011: How would you google this?

Pivotal Labs
Wednesday, January 19, 2011

Ask for Help

“Anyone using Selenium 2 and Webdriver?”

One of our internal projects is using it.

“How to stop time in Jasmine?”

There were a couple suggestions:

  • use a global function, such as ‘now’
  • send in your own clock object

“Whurl standalone, or more dynos?”

Apparently Whurl is running on a single dyno at Heroku, so a single bad request can tie up Whurl until the request times out. Where are you TildeWill?

“What’s this called?”

Imagin these are records in a relational database, with the records on the left having a one to many relationship with the records on the right. How would you google this?

one to many diagram

  • 0 Shares
  • Share on Facebook
  • Share on Twitter
Pivotal Labs

Standup Tuesday, 1/18/2011: Experience with head.js?

Pivotal Labs
Tuesday, January 18, 2011

Ask for Help

“Any experience using head.js?”

No one stepped forward with actual experience.

  • 0 Shares
  • Share on Facebook
  • Share on Twitter
Mike Gehard

Capybara/Cucumber and waiting for Javascripty stuff to happen

Mike Gehard
Friday, August 20, 2010

A little ditty that makes it really easy to wait for something Javascripty to happen…like a Javascript dialog to appear that gets populated from an AJAX call.

The has_css? method call will wait until the element shows up and if it doesn’t show up before the Capybara timeout expires then it will return false.

  • 0 Shares
  • Share on Facebook
  • Share on Twitter
Abhijit Hiremagalur

Standup 08/04/2010: Accounting on Rails anybody?

Abhijit Hiremagalur
Wednesday, August 4, 2010

Ask for Help

  • Double-entry/ledger based accounting in Rails (i.e. Quickbooks in Rails for free)

Ideally would be tied in with user/role system where each accounting entry would be tied to a user, but also reconciled against a master account.

Recommendations? Latest and greatest?

One suggestion was to look at the code that Wesabe open sourced code when they closed their doors.

  • Error message when opening Rubymine “Invalid Git Root”

This is likely because the project included a submodule that wasn’t configured correctly, fix this in under Rubymine’s version control preferences.

Add submodule screen in Rubymine

Interesting Things

  • Test 404 handling (e.g. rescue_from ActiveRecord::RecordNotFound, :with => :render_record_not_found) with Cucumber by temporarily setting ActionController::Base.allow_rescue = true. This is usually set to false in features/support/env.rb
  • JSON.pretty_generate hates Rails 3 Hashes

 

  • Use window.postMessage to communicate between IFrames in a standard way

This should work in most modern browsers. Follow the Mozilla docs, NOT the various blog posts about this.

  • 0 Shares
  • Share on Facebook
  • Share on Twitter

Topics

  • agile (780)
  • rails (113)
  • testing (88)
  • ruby (83)
  • ruby on rails (70)
  • jobs (62)
  • javascript (55)
  • techtalk (44)
  • rspec (38)
  • ironblogger (32)
  • productivity (30)
  • activerecord (29)
  • gogaruco (29)
  • git (28)
  • nyc (27)
  • rubymine (26)
  • bloggerdome (23)
  • mobile (22)
  • process (21)
  • pivotal tracker (20)
  • cucumber (20)
  • jasmine (19)
  • design (18)
  • ios (18)
  • webos (17)
  • objective-c (17)
  • android (16)
  • palm (16)
  • "soft" ware (16)
  • fun (15)
  • tracker ecosystem (15)
  • ci (15)
  • cedar (15)
  • rails3 (14)
  • performance (14)
  • bdd (14)
  • gem (13)
  • css (13)
  • tdd (13)
  • selenium (12)
  • goruco (12)
  • bundler (12)
  • meetup (11)
  • railsconf (11)
  • nyc-standup (11)
  • capybara (10)
  • mac (10)
  • mojo (10)
  • chef (10)
  • api (10)
Subscribe to javascript Feed
  1. ←
  2. 1
  3. 2
  4. 3
  5. 4
  6. 5
  7. 6
  8. →
  • About
  • Case Studies
  • Team
  • Community
  • Careers
  • Contact
  • Labs
  • Events

Contact Us

contact@pivotallabs.com
+1 415-77-PIVOT
TwitterLinkedInFacebook

Pivotal Tracker

Tracker is the award-winning agile project management tool that enables real-time collaboration around a shared, prioritized backlog.
Visit pivotaltracker.com >