편집 버튼을 클릭하는 동안 새 창을 팝업하는 작업이 있습니다. 그러나이 문제에 대한 해결책은 없습니다. 클래스 학생과 세 가지 속성 이름, 나이 및 지점이 있습니다. 스캐 폴딩을 통해 뷰를 만들었습니다. 나에게 할당 된 작업은 편집 버튼을 클릭하는 동안 해당 속성을 편집 할 수있는 팝업 창이 있어야합니다. 어떻게해야합니까? 제발 도와 줘 .JTable처럼 이걸하고 싶다. 이이 학생 클래스의레일 위의 루비 팝업 창
<table class="tablelist">
<caption>Listing students</caption>
<tr>
<th>Name</th>
<th>Age</th>
<th>Branch</th>
<th></th>
<th></th>
</tr>
<% @students.each do |student| %>
<tr>
<td><%= student.name %></td>
<td><%= student.age %></td>
<td><%= student.branch %></td>
<td><%=link_to (image_tag("edit.png", :alt => 'Edit'), edit_student_path(student)) %></td>
<td><%= link_to 'Destroy', student, :method => :delete, :data => { :confirm => 'Are you sure?' } %></td>
</tr>
<% end %>
</table>
<br />
<%= link_to 'New Student', new_student_path %>
컨트롤러 내 index.html.erb입니다
def list
@students = Student.all
@jtable = {'Result' => 'OK','Records' => @students.map(&:attributes)}
respond_to do |format|
format.html # index.html.erb
format.json { render :json => @jtable}
end
end
index.html.erb가 routes.rb이
<html>
<head>
<%=stylesheet_link_tag "jtable_blue","http://code.jquery.com/ui/1.9.1/themes/base/jquery-ui.css",:media => "all" %>
<%= javascript_include_tag "jquery-1.8.3.min","http://code.jquery.com/ui/1.9.1/jquery-ui.js","jquery.jtable.min"%>
<script type="text/javascript">
jQuery.noConflict();
jQuery(document).ready(function() {
jQuery('#StudentTableContainer').jtable({
title: 'StudentList',
actions: {
listAction: '/students/list',
createAction: '/students/newstudent',
updateAction: '/students/edit',
deleteAction: '/students/destroy'
},
fields: {
id: {
key: true,
create: false,
edit: false,
list: false
},
name: {
title: 'name',
width: '40%'
},
sex: {
title: 'sex',
width: '20%'
},
branch: {
title: 'branch',
width: '30%'
}
}
});
jQuery('#StudentTableContainer').jtable('load');
});
</script>
</head>
<body>
<div id="StudentTableContainer">
</div>
</body>
</html>
입니다
match 'students/list' => 'students#list', :as => :list
jtable처럼하고 싶습니다. 좋은 생각이야? – Niths
자신 만의 시도를하고 또한 질문에 답을 표시하는 것을 고려해야합니다. – sunnyrjuneja
내 대답을 본 것 같아. – Niths