Sha256: c23afeda03daafa6f99f206be2f5f6078d566c87f4f88d51a50c5a917a08dc22

Contents?: true

Size: 1.09 KB

Versions: 2

Compression:

Stored size: 1.09 KB

Contents

// This is a manifest file that'll be compiled into application.js, which will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
// or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
//
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// compiled file. JavaScript code in this file should be added after the last require_* statement.
//
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
// about supported directives.
//
//= require jquery3
//= require jquery_ujs
//= require popper
//= require bootstrap-sprockets
//= require_tree .

window.addEventListener('load', () => {
  $('.article').on('show.bs.collapse', e => {
    const target = e.currentTarget;
    const articleId = target.dataset.id;
    target.textContent = 'loading...';

    fetch(`/articles/${articleId}.json`).then(r => r.json()).then(r => target.innerHTML = r.body).catch(() => console.log('error'));
  });
});

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
mini_blog-0.1.1 app/assets/javascripts/mini_blog/application.js
mini_blog-0.1.0 app/assets/javascripts/mini_blog/application.js