Adamhumbug Posted December 17, 2019 Share Posted December 17, 2019 Hi, i am populating a modal and from this modal, another modal is populated to confirm a delete. I populate the first modal using button.data I need the user id to be put onto the delete button in the first modal so it can be passed to the second. The following is how i build the modal: $('#userModal').on('show.bs.modal', function(event) { // Button that triggered the modal var button = $(event.relatedTarget) //data elements var userid = button.data('userid') var firstname = button.data('firstname') var lastname = button.data('lastname') var email = button.data('email') var level = button.data('accountlevel') var mobile = button.data('mobile') var role = button.data('role') var modal = $(this) modal.find('.modal-title').text('Update User') modal.find('.modal-body #UM-uid').val(userid) modal.find('.modal-body #UM-firstname').val(firstname) modal.find('.modal-body #UM-lastname').val(lastname) modal.find('.modal-body #UM-emailAddress').val(email) modal.find('.modal-body #UM-accountLevelId').val(level) modal.find('.modal-body #UM-mobileNumber').val(mobile) modal.find('.modal-body #UM-roleId').val(role) var x = modal.find('#callDeleteUserConf'); x.dataset.userid = button.data('userid') }) i get x.dataset is undefined Any help/advice on this would be appreciated Kind Regards Adam Quote Link to comment https://forums.phpfreaks.com/topic/309698-set-a-data-element-with-js/ Share on other sites More sharing options...
Adamhumbug Posted December 17, 2019 Author Share Posted December 17, 2019 I actually fixed this by simply changing the following from x.dataset to x[0].dataset Quote Link to comment https://forums.phpfreaks.com/topic/309698-set-a-data-element-with-js/#findComment-1572579 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.