I have this html code:
<a data-id="test" title ="Add this item" class="open-AddBookDialog btn btn-primary" href="#addBookDialog">test</a> which opens a modal and passes data is passed from the parent to th modal. It works fine but I need the data passed to be the input from a textbox.
The script:
$(document).on("click", ".open-AddBookDialog", function (e) {
e.preventDefault();
var _self = $(this);
var myBookId = _self.data('id');
$("#bookId").val(myBookId);
$(_self.attr('href')).modal('show');
});
It takes the value of data-id and displays on my modal.
I need to make data-id receive a variable or an input from a text box.
<a data-id="test" title ="Add this item" class="open-AddBookDialog btn btn-primary" href="#addBookDialog">test</a> which opens a modal and passes data is passed from the parent to th modal. It works fine but I need the data passed to be the input from a textbox.
The script:
$(document).on("click", ".open-AddBookDialog", function (e) {
e.preventDefault();
var _self = $(this);
var myBookId = _self.data('id');
$("#bookId").val(myBookId);
$(_self.attr('href')).modal('show');
});
It takes the value of data-id and displays on my modal.
I need to make data-id receive a variable or an input from a text box.