Ruby on rails 在引导模式下使用jquery、ajax的CRUD模型——最佳实践
我有一个模型,我想通过ajax在对话框中显示编辑和更新。 我现在做的是: 为了打开模式并呈现部分,我向controller#show with ujs发送了一个ajax请求 这是链接:Ruby on rails 在引导模式下使用jquery、ajax的CRUD模型——最佳实践,ruby-on-rails,json,jquery,twitter-bootstrap,dialog,Ruby On Rails,Json,Jquery,Twitter Bootstrap,Dialog,我有一个模型,我想通过ajax在对话框中显示编辑和更新。 我现在做的是: 为了打开模式并呈现部分,我向controller#show with ujs发送了一个ajax请求 这是链接: <a class="person-dialog" data-remote="true" data-type="script" href="/en/people/32" onclick="return false">Fidel Markus Armstrong</a> 如果问题不够清楚,
<a class="person-dialog" data-remote="true" data-type="script" href="/en/people/32"
onclick="return false">Fidel Markus Armstrong</a>
如果问题不够清楚,请发表评论
<a class="person-dialog" data-remote="true" data-type="script"
href="/en/people/32/edit" onclick="return false">Fidel Markus Armstrong</a>
<form accept-charset="UTF-8" action="/en/people/32" class="form-horizontal"
data-remote="true" data-type="json" id="edit_person_32" method="post">
$('#dialog').on('submit', ->
$(this).find('form').bind('ajax:success',(evt, data, status, xhr) ->
if xhr.status == 201 # :created
url = data.url #this is en/people/:id
#Load show dialog on success - runs show.js.erb
$.ajax({
url: url,
type: 'get',
dataType: 'script'
})
else
#Render the dialog html including the error messages and fields with errors
#data.error is the partial
$('#person-dialog').html(data.error)
$('.field_with_errors input').first().trigger('focus')
$('.modal-header').prepend('edit')
)