use link_to_function + rjs in the view to generate js without an ajax call. example:
link_to_function "Click Me", update_page {|page|
page.alert "No postback!"
}
consider putting custom js functions that should be globally available in public/javascripts/application.js (this is included by javascript_include_tag :defaults)
page.select will fetch things by id or class
page.select('#tasks div a').each do |item|
page.hide item
end
use a method name in a string var as a function call
page.send 'method_name', param
replace/replace_html for outside/inside an element with page.replace_html
page.replace_html 'task_totals', @task_totals
insert your own custom js into the page with < <
page < < "my_js_method()"
or -
page < < %(
my_js_method();
function some_other_func() { ... }
)
or -
page < < render :partial => "update_totals"
assign js vars with values from ruby with page.assign
page.assign 'task_totals', @task_totals
keep users informed of ajax calls during link_to_remote calls with :loading and :complete callbacks
link_to_remote "Click Me",
:url => tasks_url(:action => 'hello'),
:loading => "Element.show('loading_div')",
:complete => "Element.hide('loading_div')"
use rjs directly in the controller with render :update
render :update do |page|
page.alert('whatever')
end
Today at lunch, my co-workers and I were discussing the disappointing news from Apple that they won’t allow third-party apps to be installed on iPhone, to which I exclaimed:
Not allowing you to download software onto the iPhone is like having an untouchable supermodel living in your bedroom!
Long story short: I was getting some strange errors when trying to use autotest with a rails app that I’m working on.
Here’s the error I got:
[note: path edited...]/action_web_service/container/action_controller_container.rb:76:in `require_web_service_api’: neither _api or _api found (NameError)
[... lots more output ...]
/usr/local/lib/ruby/gems/1.8/gems/ZenTest-3.2.0/lib/unit_diff.rb:196:in `unit_diff’: undefined method `first’ for nil:NilClass (NoMethodError)
from /usr/local/lib/ruby/gems/1.8/gems/ZenTest-3.2.0/lib/unit_diff.rb:84:in `unit_diff’
from /usr/local/lib/ruby/gems/1.8/gems/ZenTest-3.2.0/bin/unit_diff:38
from /usr/local/bin/unit_diff:18
# Test::Unit exited without a parseable failure or error message.
# You probably have a syntax error in your code.
# I’ll retry in 10 seconds
I managed to fix it by rebuilding my entire rails environment using the helpful instructions linked to from the rails site. Thanks Hivelogic!
I was there at the opening of Apple’s new 5th Ave retail store. They recorded a timelapse video of all the poor blokes waiting in line (like me). And yes, because I’m so nerdy, I downloaded the movie and found the frames that Abel and I are captured in.
Look, if you’re on a Mac, and you do any sort of text editing (html, programming, whatever) and you’re not using Textmate, you SHOULD be. It’s worth the price, I promise. (And there’s a 30 day free trial anyway.) Just a friendly reminder. =-)
OK, so I don’t have an unnatural ability to recognize natural bird sounds, but I did successfully recognize my first bird call the other weekend in the park, thanks to my Birding by Ear CDs! It was a White-throated Sparrow and it sounded pretty much exactly like the samples on the CDs. I’ve clearly got a long way to go, but it feels encouraging to know that I might have some potential at learning bird songs to help make me a better birder. I’m so old!
Ok, update: I ordered a new gaming box, and I should have it by the end of the month. I can’t wait to play Half-Life 2!
To keep me busy until then, because it’s Spring and it’s driving me crazy that I can’t ID all the bird calls I’m hearing in the park, I’ve ordered Birding by Ear and it’s companion More Birding by Ear, which I should have in two days thanks to Amazon. Yes, I’m soo many different kinds of nerd it’s crazy, I know.
It’s been so quiet here lately (thanks to me just being off doing other things and not feeling in much of a blogging mood), and I feel kinda bad for the four readers of this blog (are any of you left?).
Current news is that my bitchass 6 year old PC died last weekend and I’ve been obsessing all week over what I should do about it. Currently leaning toward (read ‘drooling over’) getting a whole custom system. I really want to be able to play some of the pretty games that I couldn’t play on my old box (HalfLife2, Farcry, Doom3, Age of Empires 3, WoW with all the settings turned up, etc). Maybe I’ll go buy it today… ;-)