Sha256: b2ba48a0cf9eba2bb65b181f922c42ba8567a146d02dd3c248001829a1fa3ef8

Contents?: true

Size: 1.56 KB

Versions: 2

Compression:

Stored size: 1.56 KB

Contents

if ($('.ui.modals').length === 0) {
  $('body').append('<%= j(render 'single') %>');
} else {
  $('.ui.modals').html('<%= j(render 'single') %>');
}

$('#good_serves_index').modal({
  onHidden: function(){
    location.reload();
  },
  autofocus: false
}).modal('show');

$('.ui.slider.checkbox').checkbox({
  onChecked: function(){
    var url = this.dataset['url'];
    var params = {
      method: 'POST',
      credentials: 'include',
      headers: {
        'Content-Type': 'application/javascript',
        'X-CSRF-Token': document.head.querySelector("[name=csrf-token]").content
      }
    };
    fetch(url, params).then(function(response) {
      return response.text()
    }).then(function(response) {
      var script = document.createElement('script');
      script.text = response;
      document.head.appendChild(script).parentNode.removeChild(script);
    }).catch(function(ex) {
      console.log('parsing failed', ex)
    })
  },
  onUnchecked: function(){
    var url = this.dataset['url'];
    var params = {
      method: 'DELETE',
      credentials: 'include',
      headers: {
        'Content-Type': 'application/javascript',
        'X-CSRF-Token': document.head.querySelector("[name=csrf-token]").content
      }
    };
    fetch(url, params).then(function(response) {
      return response.text()
    }).then(function(response) {
      var script = document.createElement('script');
      script.text = response;
      document.head.appendChild(script).parentNode.removeChild(script);
    }).catch(function(ex) {
      console.log('parsing failed', ex)
    })
  }
});

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rails_trade-0.0.2 app/views/trade/admin/cart_item_serves/single.js.erb
rails_trade-0.0.1 app/views/rails_trade_admin/cart_item_serves/single.js.erb