Skip to content

Instantly share code, notes, and snippets.

@Sunnyztj
Last active November 12, 2018 07:39
Show Gist options
  • Save Sunnyztj/50a327db02005311e5c8ee5845df745e to your computer and use it in GitHub Desktop.
Save Sunnyztj/50a327db02005311e5c8ee5845df745e to your computer and use it in GitHub Desktop.
select2 in rails 5 => Javascript not executing
js:
$(document).on('turbolinks:load',function(){
$(document).ready(function(){
$("#modalBtn").click(function(){
$("#newProject").modal("show");
});
$("#newProject").on('show.bs.modal', function () {
flatpickr('#project_deadline_for_budget_preparation', {
altInput: true,
altFormat: "F j, Y",
dateFormat: "Y-m-d",
});
flatpickr('#project_expect_construction_start_at', {
altInput: true,
altFormat: "F j, Y",
dateFormat: "Y-m-d",
});
});
});
});
html:
%button.btn.btn-success.btn-sm{"data-target" => "#newProject", "data-toggle" => "modal", :type => "button", :id => "modalBtn"}
New project
/ Modal
#newProject.modal.fade{"aria-hidden" => "true", "aria-labelledby" => "newProjectTitle", :role => "dialog", :tabindex => "-1"}
.modal-dialog.modal-dialog-centered{:role => "document"}
.modal-content
.modal-header
%h5#exampleModalLongTitle.modal-title New project
%button.close{"aria-label" => "Close", "data-dismiss" => "modal", :type => "button"}
%span{"aria-hidden" => "true"} ×
= simple_form_for Project.new do |f|
.modal-body
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment