Skip to content

Instantly share code, notes, and snippets.

@milinmestry
Created June 14, 2019 08:36
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 milinmestry/f361d1d955be6822d2f595080735a7c9 to your computer and use it in GitHub Desktop.
Save milinmestry/f361d1d955be6822d2f595080735a7c9 to your computer and use it in GitHub Desktop.
Bootstrap Modal data attributes
h2. My Observation on Bootstrap Modal data attributes
=======
I have added to data-* attributes for Modal window to pass data on to display.
Data attributes are-
#data-fyid
#data-fyHead
In the JavaScript code-
`
$('#fy_modal').on('show.bs.modal', function (event) {
let button = $(event.relatedTarget) // Button that triggered the modal
let fyid = button.data('fyid') // This give me the actual integer ID in modal
// let fyhead = button.data('fyHead'); // This will return value as undefined
let fyhead = button.data('fyhead'); // This will return correct value
....
});
`
So to get the value for **data-fyHead** attribute, I have to chage the case of the variable to **data-fyhead**, this solve my problem.
I learn that camelcase is not supported in Bootstrap modal to pass data via attributes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment