You are talking about two very different types of campaigns, primary and general elections, and equating them.
The things that motivate conservatives to vote for a candidate, do not work on moderate and liberal voters. Attacking Obama would have motivated conservatives to vote for McCain, but would also motivate liberals to vote for Obama, and turn off moderate voters. Candidates need over 50% of the vote to win. A winning Republican tries to get most of the conservative vote and most of the moderate vote, while suppressing the liberal vote...that is why smart politicians use a proxy to attack their opponent in a general election.
In a primary, both candidates are going after the same conservative voters...so pointing out that JD was a hypocritical, big government spending, entitlement pushing infomercial salesman, that couldn't win reelection in his tiny little congressional district, didn't hurt McCain with conservative voters.
If I were in McCain's place, I definitely would have ran that risk. I would have defined myself starkly against Obama made people chose. I damn sure wouldn't have suspended my campaign to fill the treasury with more IOUs made in the name of the American people.