Thursday, November 20, 2008

Google's AJAX Libraries API

for those that use YUI:

googles info:

The AJAX Libraries API is a content distribution network and loading architecture for the most popular open source JavaScript libraries. By using the google.load() method, your application has high speed, globally available access to a growing list of the most popular JavaScript open source libraries.

They also host

  • jQuery
  • jQuery UI
  • Prototype
  • script_aculo_us
  • MooTools
  • Dojo
  • SWFObjectNew!
They also list what versions they host.

Wednesday, October 29, 2008

Adobe - Developer Center : Using Ajax to retrieve data from ColdFusion

Adobe - Developer Center : Using Ajax to retrieve data from ColdFusion

Adobe Platform Evangelist Adam Lehman demonstrates how easy it is to populate drop-down lists in a simple application with data from ColdFusion.

Monday, August 11, 2008

Navigating The Science (And Sociology) Of 'Traffic' : NPR

Navigating The Science (And Sociology) Of 'Traffic' : NPR

Vanderbilt's book Traffic: Why We Drive the Way We Do (and What It Says About Us) explores the sociology of driving — why roads are most congested on Saturdays, what percentage of traffic is drivers simply looking for parking, why new cars crash more often than old ones. The book is based on research and interviews with driving experts and traffic officials around the world.

Thursday, June 05, 2008

Dreamweaver CS3 bug?

working on some CSS and added
#header { background-color: ccc; }
to the style shee. looked OK when I refreshe the Design view in dreamweaver. previewed it in a browser. There was no background color. I checked to make sure the link paths were correct. I soon noticed I didn't have the # before the color value. D'oh!

Monday, February 11, 2008

I needed a refresher with RJS so I watched Peepcode’s screencast on RJS. I know it was not rails 2 so I decided to share what I changed to make it work with rails 2.

I used the SQL lite db for the demo. To set it up I created the rails project
rails rjs_demo

I used the scaffold to get it off the ground
script/generate scaffold Task name:string value:integer
And that will take care of the CRUD, routes and all that fun stuff.

You don’t need the dom_id plugin we can use the div_for

I’m just used the index.html.erb file instead of making a list file.

I added to the routes file
:collection => { :hello => :any }
To the map.resources :tasks line and the link now says
map.resources :tasks, :collection => { :hello => :any }

The link for the say hello
<%= link_to_remote "Say Hello", :url => hello_tasks_path %>
Instead of
<%= link_to_remote "Say Hello", :url => tasks_url(:action => 'hello') %>

In the tasks_controller.rb add a hello method.
def hello respond_to do |format| format.js end end

add into the views/tasks folder the file hello.js.rjs
page.alert "hello world!"

For the tasks partial create the _task.html.erb file.
With rails 2 you can call a partial but using <%= render :partial => @tasks %>
and then in the task instead of using the dom_id you can use the div_for

Highlight me.
In routes file I added
:member => { :highlight => :post }
to the map.resources :tasks line. It should read
map.resources :tasks, :collection => { :hello => :any }, :member => { :highlight => :post }

that gives us the route
highlight_task POST /tasks/:id/highlight {:action=>"highlight", :controller=>"tasks"}

so the link is <%= link_to_remote "highlight me ", :url => highlight_task_path(task) %>

In the controller
def highlight @task = Task.find(params[:id]) respond_to do |format| format.js end end

And make the highlight.js.rjs file

the form.
you can use the remote_form_for
<%= error_messages_for :task %> <% remote_form_for(:task, :url => tasks_path, :html => {:id => "task_form"}) do |f| %> <p> <b>Name</b><br /> <%= f.text_field :name %> </p> <p> <b>Value</b><br /> <%= f.text_field :value %> </p> <p> <%= f.submit "Create" %> </p> <% end %>

And in the index.html.erb file call the partial
<%= render :partial => 'form' %>

Don't forget the add the format.js in the is @save section

Now make the create.js.rjs file
page.insert_html :bottom, 'tasks', :partial => @task page['task_form'].reset
When adding the super_special class I changed the link to "set_class_name", "task_#{}", 'super_special'
and it works

now destroy
In the destroy.js.rjs file
page.remove "task_#{}"
and add the format.js to the destroy method.
The destroy link will look like.
<%= link_to_remote "destroy", :url => task_path(task), :method => :delete, :confirm => "Do you want to delete '#{}'?" %>

_totals.js.rjs file I used this line
page.replace_html 'task_totals', @task_totals

The shared error file
create the shared folder and add an error.js.rjs file to it
the code it the same in the rjs file
in the tasks_controller in the condidtional andd this for an error
format.js { render :template => "shared/error.js.rjs" }
that will make the popup work.

These are my rough notes.


Blog Archive