问题
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