在 netzke rails3 中添加动作

Add action in netzke rails3

我在 https://github.com/netzke/netzke/wiki/Adding-custom-actions-to-a-component 写了这篇文档 但是我不明白这个。

undefined method `js_method'

完整组件代码

class Airports < Netzke::Basepack::Grid
include Netzke::Basepack::ActionColumn

js_method :on_show_details, <<-JS
  function(){
    var tmpl = new Ext.Template("<b>{0}</b>: {1}<br/>"), html = "";

    Ext.iterate(this.getSelectionModel().selected.first().data, function(key, value){
      html += tmpl.apply([key.humanize(), value]);
    }, this);

    Ext.Msg.show({
      title: "Details",
      width: 300,
      msg: html
    });
  }
JS

def configure(c)
    super
    c.title = "Airports"
    c.model = "Airport"
    c.columns = [...]
  end
end

为什么会出现此错误?

undefined method `js_method' for Airports:Class
Extracted source (around line #2):

1: <h1>Аэропорты</h1>
2: <%= netzke :airports,
3: #  :class_name => "Netzke::Basepack::Grid",
4:   :border => true,

请帮帮我! 我想向上下文菜单添加操作。

我回答。 我已经写了change.log,我得到了这个东西。

js_configure do |c|
  c.on_show = <<-JS
  function(){
    var tmpl = new Ext.Template("<b>{0}</b>: {1}<br/>"), html = "";

    Ext.iterate(this.getSelectionModel().selected.first().data, function(key, value){
      html += tmpl.apply([key.humanize(), value]);
    }, this);

    Ext.Msg.show({
      title: "Details",
      width: 300,
      msg: html
    });
  }
  JS
end

现在正在运行!!!