Skip to content

Instantly share code, notes, and snippets.

@bchase
Created October 10, 2018 20:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bchase/a7e3d902455d94ec32358fd8dd8cad03 to your computer and use it in GitHub Desktop.
Save bchase/a7e3d902455d94ec32358fd8dd8cad03 to your computer and use it in GitHub Desktop.
Job.prototype.appliedButton = function() {
let text = this.applied ? 'Mark as not applied to' : 'Mark as applied to'
// return $('<button>', {id: 'add-applied', data: {bool: applied}, text: text, className: 'foo'})
return `<button id='add-applied' data-bool="${this.applied}">${text}</button><br><br>`
}
// app/assets/javascripts/jobs/show.js
$(document).ready(function(){
const displayJobDetails = function (job) {
$('#foo').append(JobView.renderJobShow(job))
}
})
// // jobs/show.html.erb
// ...
// = javascript_tag 'jobs/show.js' ^
// app/assets/javascripts/job/view/JobView.js
class JobView {
static renderJobShow(job) {
$('<div>', {}, [ renderJobTitle(job), ... ])
}
static renderJobTitle(job) { ... }
static renderJobAppliedBtn(job) { ... }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment