Screencast: Kalender-Funktion
Es gibt verschiedene Möglichkeiten um einem Benutzer ein Datum auswählen zu lassen oder einen Kalender zu präsentieren. In dieser Woche zeigt Ryan einige Beispiele und Lösungen dafür.
Download:
Download(15.6 MB, 9:50)
Alternativer Downloadfür iPod & Apple TV(14.9 MB, 9:50)
Resourcen:
- calendar_date_select
- jQuery UI Datepicker
- event_calendar
- table_builder
- Episode 205: Unobtrusive Javascript
- Full episode source code
Quellcode:
script/plugin install git://github.com/p8/table_builder.git
# articles_controller.rb def index @articles = Article.find(:all) @date = params[:month] ? Date.parse(params[:month]) : Date.today endv
<!-- layouts/application.html.erb -->
<%= stylesheet_link_tag "http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/themes/redmond/jquery-ui.css", "application" %>
<%= javascript_include_tag "http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js", "http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.1/jquery-ui.min.js", "application" %>
<!-- articles/index.html.erb -->
<div id="calendar">
<h2 id="month">
<%= link_to "<", :month => (@date.beginning_of_month-1).strftime("%Y-%m") %>
<%=h @date.strftime("%B %Y") %>
<%= link_to ">", :month => (@date.end_of_month+1).strftime("%Y-%m") %>
</h2>
<% calendar_for @articles, :year => @date.year, :month => @date.month do |calendar| %>
<%= calendar.head('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday') %>
<% calendar.day(:day_method => :published_on) do |date, articles| %>
<%= date.day %>
<ul>
<% for article in articles %>
<li><%= link_to h(article.name), article %></li>
<% end %>
</ul>
<% end %>
<% end %>
</div>
<!-- articles/_form.html.erb -->
<%= f.text_field :published_on %>
// application.js
$(function() {
$("#article_published_on").datepicker();
});
#calendar table {
border-collapse: collapse;
width: 100%;
}
#calendar td,
#calendar th {
font-family: "Lucida Grande",arial,helvetica,sans-serif;
font-size: 10px;
padding: 6px;
border: 1px solid #999;
}
#calendar th {
background: #DDD;
color: #666;
text-align: center;
width: 14.2857142857143%;
}
#calendar td {
background: #FFF;
color: #777;
height: 80px;
vertical-align: top;
font-size: 16px;
}
#calendar .notmonth {
color: #CCC;
}
#calendar #month {
margin: 0;
padding-top: 10px;
padding-bottom: 10px;
text-align: center;
}
#calendar #month a, #calendar #month a:hover {
text-decoration: none;
padding: 0 10px;
color: #999;
}
#calendar .today {
background-color: #D7F2FF;
}
#calendar ul {
margin: 0;
margin-top: 5px;
padding: 0;
list-style: none;
}
#calendar li {
margin: 0;
padding: 0;
font-size: 11px;
text-align: center;
}
Eingestellt am 10.05.2010 um 13:03
Kategorie: Tutorials
Suchen auf rubyonrails.de
Tags
2.0 Action Active-Record ActiveRecord Ajax Buch Capistrano Enterprise Event Formulare Gewinnspiel Grundlagen IDE irb jQuery Kochbuch Konferenz Mac OpenRoRBook OReilly OSX Passenger Phusion Plugin PragProgs Rails Rails 3 RailsWayCon Release Release Candidate Routing Ruby Ruby 1.9 RubyGems rubyonrails.de Ryan Bates Scaffolding Screencast Script-Tip Security Tutorial Upgrade Video Views WindowsAktuelle Artikel
- Scripttip: Herausfinden ob ein Datum in einen bestimmen Zeitraum fällt
- Scripttip: Herausfinden ob ein Wert numerisch ist
- Screencast: Resourcen vererben
- Ruby on Rails 2.3.9 veröffentlicht
- Alle Links zu Rails 3
- Rails 3 Upgrade Handbook PDF
- Ruby on Rails 3: Moderne Webentwicklung mit Ruby
- Rails 3.0 ist fertig
- Screencast: Polling nach Aktualisierungen
- Screencast: Sortierbare Tabellen
Artikel Archiv
- September 2010
- August 2010
- July 2010
- June 2010
- May 2010
- April 2010
- March 2010
- February 2010
- January 2010
- December 2009
- November 2009
- October 2009
- September 2009
- August 2009
- July 2009
- May 2009
- April 2009
- March 2009
- February 2009
- December 2008
- November 2008
- August 2008
- July 2008
- June 2008
- May 2008
- March 2008
- February 2008
- January 2008
- December 2007
- November 2007
- October 2007
- September 2007
Aktuelle Rails Version + Abhängigkeiten:
Gem rails-3.0.0actionmailer (= 3.0.0, runtime)
actionpack (= 3.0.0, runtime)
activerecord (= 3.0.0, runtime)
activeresource (= 3.0.0, runtime)
activesupport (= 3.0.0, runtime)
bundler (~> 1.0.0, runtime)
railties (= 3.0.0, runtime)
Rails auf Rubyforge
Rails auf Github