Jump to content

Set a data element with JS


Adamhumbug

Recommended Posts

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.