Last active
October 10, 2018 22:15
-
-
Save bchase/d7de221b4db6633669d360237d3deaec to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// app/assets/javascripts/App.js | |
class App { | |
static initJobShow() { | |
$(document).ready(function(){ | |
let user_id = $(".user-id").data("id") | |
let job_id = $(".job-id").data("id") | |
$.get(`/users/${user_id}/jobs/${job_id}.json`, function(data) { | |
let job = new Job(date, user_id) | |
$('#foo').append(JobView.renderJobShow(job)) | |
}) | |
}) | |
} | |
static initJobIndex() { | |
// ... | |
} | |
} | |
// app/assets/javascripts/job/view/JobView.js | |
class JobView { | |
static renderJobShow(job) { | |
$('<div>', {}, [ renderJobTitle(job), ... ]) | |
} | |
static renderJobTitle(job) { ... } | |
static renderJobAppliedBtn(job) { ... } | |
} | |
// ///// app/views/layout/application.html.erb ///// | |
// | |
// ... | |
// | |
// = javascript_tag 'App.js' # ^ our `App` class above | |
// ///// app/views/jobs/show.html.erb ///// | |
// | |
// ... | |
// | |
// <script type='text/javascript'> | |
// App.initJobShow() | |
// </script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment