title: How to invoke javascript function every time after another function?
body: <p>I have two tables and I move particular rows among them when clicking corresponding checkboxes.
  Besides checkboxes each row contains in-line editing fields thanks to x-editable library.</p>
  
  <p>The problem is when I move some row into another table I can't edit its fields anymore. It seems like setXeditable() runs only one time and then after invoking another java script it doesn't get executed. I have to reload the page to be able to edit these fields again. How can I solve it?</p>
  
  <p><strong>application.js</strong></p>
  
  <pre><code>//= require jquery
  //= require jquery.turbolinks
  //= require jquery_ujs
  //= require turbolinks
  //= require bootstrap-sprockets
  //= require bootstrap3-editable/bootstrap-editable
  //= require bootstrap-datepicker/core
  //= require bootstrap-datepicker
  //= require_tree .
  
  #x-editable
  
  var setXeditable;
  
  $.fn.editable.defaults.mode = 'inline';
  
  setXeditable = function() {
    return $("[data-xeditable=true]").each(function() {
      return $(this).editable({
        ajaxOptions: {
          type: "PUT",
          dataType: "json"
        },
        params: function(params) {
          var railsParams;
          railsParams = {};
          railsParams[$(this).data("model")] = {};
          railsParams[$(this).data("model")][params.name] = params.value;
          return railsParams;
        }
      });
    });
  };
  
  #function that moves rows
  
  function pressing(arg){
        user_id = $(arg).attr('data-user-id')
        id = $(arg).attr('data-id')
        value = $(arg).is(":checked")
        $(arg).attr('data-id')
        html=$(arg).closest("tr")
        $(arg).closest("tr").remove()
        path = '/users/' + user_id + '/tasks/' + id
  
         if(value){
           complete = true;
           $('.completed-tasks').append(html)
         }
         else{
           complete = false;
            $('.incompleted-tasks').append(html)
          }
  
        $.ajax({
          url : path,
          type : 'PUT',
          dataType: "json",
          data: { task: {id: id, complete: value}}
        })
      }
  </code></pre>
  
  <p>I'm calling setXeditable() in my <strong>index.js</strong></p>
  
  <pre><code>$("#all-tasks").html("&lt;%= j render 'index' %&gt;")
  
  setXeditable()
  </code></pre>