some update for list of pages
This commit is contained in:
parent
f68ee92d5a
commit
03f44469df
|
@ -24,8 +24,8 @@
|
|||
<td><%= format_value page.page_contexts.last.updated_at rescue nil %></td>
|
||||
<td><%= User.find(page.page_contexts.last.update_user_id).user_name rescue nil %></td>
|
||||
<td>
|
||||
<%= select_tag("category_id",options_for_select(@categories, (page.category_id.to_s rescue "")), prompt: "Select a category", class: "category_select", style: "margin-bottom:0;") %>
|
||||
<button <%= !page.category_id.nil? ? "data-page-category-id=#{page.category_id.to_s}" : "" %> data-page-id="<%= page.id.to_s %>" id="save_category" class="btn btn-primary hide">Save</button>
|
||||
<%= select_tag("category_id",options_for_select(@categories, (page.category_id.to_s rescue "")), prompt: "Select a category", class: "category_select", style: "margin-bottom:0; width:150px;") %>
|
||||
<button <%= !page.category_id.nil? ? "data-page-category-id=#{page.category_id.to_s}" : "" %> data-page-id="<%= page.id.to_s %>" class="btn btn-primary save_category hide">Save</button>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
|
@ -41,21 +41,23 @@
|
|||
<script type="text/javascript">
|
||||
(function(){
|
||||
var category_id = null,
|
||||
button = $("button#save_category");
|
||||
buttons = $("button.save_category");
|
||||
$("select.category_select").on("change",function(){
|
||||
category_id = $(this).val()
|
||||
category_id = $(this).val();
|
||||
button = $(this).parent().find("button");
|
||||
if(category_id != ""){
|
||||
if(button.data("page-category-id") != category_id){
|
||||
$("button#save_category").removeClass("hide");
|
||||
button.removeClass("hide");
|
||||
}else{
|
||||
$("button#save_category").addClass("hide");
|
||||
button.addClass("hide");
|
||||
}
|
||||
}else{
|
||||
$("button#save_category").addClass("hide");
|
||||
button.addClass("hide");
|
||||
}
|
||||
})
|
||||
button.on("click",function(){
|
||||
var page_id = $(this).data("page-id");
|
||||
buttons.on("click",function(){
|
||||
var page_id = $(this).data("page-id"),
|
||||
button = $(this);
|
||||
if(category_id != null){
|
||||
$.ajax({
|
||||
url : "/admin/page_contents/save_category",
|
||||
|
|
Loading…
Reference in New Issue