How to use .on_delete callback in ProMotion-Formotion

不问归期 提交于 2020-01-01 19:33:28

问题


I use ProMotion with PM::FormotionScreen screen.

How to use row.on_delete callback from Formotion in ProMotion?

I have this table_data method

  def table_data
    {
      sections: [{
          rows: [

          {
          title: "URL",
          key: :url,
          placeholder: "http://myapp/dj_mon/",
          action: :delete_account,
          deletable: true,
          type: :string,
          auto_correction: :no,
          auto_capitalization: :none
          }

          ]
        }]
    }
  end

screenshot: http://i.stack.imgur.com/e1dlu.png


回答1:


Instead of using a hash to initialize the Formotion form, you'll have to use the DSL:

form = Formotion::Form.new

form.build_section do |section|
  section.build_row do |row|
    row.title               = 'URL'
    row.key                 = :url
    row.placeholder         = "http://myapp/dj_mon/"
    row.type                = :string
    row.auto_correction     = :no
    row.auto_capitalization = :none
    row.deletable           = true

    row.on_tap do |row|
      p "I'm tapped!"
    end

    row.on_delete do |row|
     p "I'm called before the delete animation"
    end
  end
end


来源:https://stackoverflow.com/questions/17898991/how-to-use-on-delete-callback-in-promotion-formotion

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!