README.rdoc in netzke-basepack-0.5.4 vs README.rdoc in netzke-basepack-0.5.5

- old
+ new

@@ -3,39 +3,48 @@ Note that if you would like to modify this code or experiment with it, you may be better off cloning this project into your app's vendor/plugin directory - it will then behave as a Rails plugin. = Prerequisites 1. Rails >= 2.2 -2. Ext JS >= 3.0: its root *must* be accessible as RAILS_ROOT/public/extjs. You may symlink your Ext JS library here like this (from your app folder): +2. Ext JS >= 3.0: its root by default must be accessible as RAILS_ROOT/public/extjs. You may symlink your Ext JS library here like this (from your app folder): + cd public && ln -s ~/Developer/extjs/ext-3.0 extjs 3. acts_as_list plugin must be installed: + ./script/plugin install git://github.com/rails/acts_as_list.git -4. mislav-will_paginate >= 2.3.0 - gem sources -a http://gems.github.com/ - sudo gem install mislav-will_paginate - = Installation -Install Netzke gems: +The gem is hosted on gemcutter. If you haven't yet enabled gemcutter, run the following: + + sudo gem install gemcutter && gem tumble + +Install the gem: + gem install netzke-basepack Include it into environment.rb: + config.gem "netzke-basepack" Include mapping for Netzke controller providing *.js and *.css (in routes.rb): + map.netzke = Usage First, run the generators to have the necessary migrations: + ./script/generate netzke_core Do the migrations: + rake db:migrate The following example will provide you with a grid-based scaffold for ActiveRecord-model called Book. You may generate it like this: + ./script/generate model Book title:string amount:integer + (don't forget to re-run the migrations after it) In the controller declare the widget: class WelcomeController < ApplicationController @@ -55,22 +64,22 @@ Declaring a widget in the controller provides you with a couple of helpers that can be used in the view: 1. books_class_definition will contain the JavaScript code defining the code for the JS class. 2. books_widget_instance will declare a local JavaScript variable called 'book'. -3. books_widget_render will provide the JavaScript code that calls the "render" method on the variable declared by books_widget_instance. +3. books_widget_render will provide the JavaScript code that calls the "render" method on the variable declared by books_widget_instance; the widget will be rendered into a div with id "books-div". Use these helpers inside of the script-tag like the following (in the view): <script type="text/javascript" charset="utf-8"> <%= books_class_definition %> Ext.onReady(function(){ <%= books_widget_instance %> <%= books_widget_render %> }) </script> - <div id="books">the widget will be rendered in this div</div> + <div id="books-div">the widget will be rendered in this div</div> If your layout already calls yield :javascripts wrapped in the <script>-tag, you can have all javascript-code in one place on the page: <% content_for :javascripts do %> <%= books_class_definition %> @@ -78,10 +87,10 @@ <%= books_widget_instance %> books.render("books"); }) <% end %> <p>... your page content here ...</p> - <div id="books">the widget will be rendered in this div</div> + <div id="books-div">the widget will be rendered in this div</div> == Dynamic loading of widgets TODO: this part will be covered later = Credentials