Sha256: 6831d4e8c37c1d3e6c682ee043f63d03ae66b60efb30ae9dbe9397040ce52335

Contents?: true

Size: 1.71 KB

Versions: 1

Compression:

Stored size: 1.71 KB

Contents

<div class="box">
  <%= render_component :"lolita/list", :title %>
  <%= render_component :"lolita/list", :new_resource%>
<div class="list">
<table>
  <%= render_component :"lolita/list", :header, :columns=>list.columns %>
  <%= render_component :"lolita/list", :body, :page=>page,:columns=>list.columns %>
</table>
</div>
<%= render_component :"lolita/list", :paginator,:page=>page, :columns=>list.columns %>
</div>

<% content_for :style do %>
  <%= stylesheet_link_tag "lolita/editable" %>
<% end %>

<script type="text/javascript">
function save_cell(name,path,input){
  var data = {
    authenticity_token: '<%= form_authenticity_token %>',
    <%= lolita_mapping.name %>: {}
  }
  data['<%= lolita_mapping.name %>'][name] = $(input).val().trim();
  $(input).attr('disabled', true);
  $.ajax({
    type: 'PUT',
    url: path,
    data: data,
    dataType: 'json',
    success: function(data){
      $(input).parent().html(data['<%= lolita_mapping.name %>'][name]);
    },
    error: function(){
      $(input).addClass("error").attr('disabled', false);
    }
  });
}
$('td.editable').live('click',function(){
  if($(this).find('input').size() == 0){
    var name    = $(this).attr('data-name');
    var value   = $(this).html().trim();
    var path    = $(this).attr('data-path');
    var input   = $('<input type="text" name="'+name+'" value="'+value+'"/>');
    input.css('width',$(this).width()+'px');
    $(this).html("");
    $(this).append(input);
    input.focus();
    var that = $(this);
    input.blur(function(){
      that.html(value);
    });
    input.keyup(function(e) {
      if(e.keyCode == 27){
        input.trigger('blur');
      }else if(e.keyCode == 13){
        save_cell(name,path,this);
      }
    });
  }
});
</script>

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
lolita-editable-list-0.1.2 app/views/components/lolita/list/editable/_display.html.erb