Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Assign attribute to newly created element. #47

Open
Kristiansky opened this issue Feb 10, 2017 · 1 comment
Open

Assign attribute to newly created element. #47

Kristiansky opened this issue Feb 10, 2017 · 1 comment

Comments

@Kristiansky
Copy link

Kristiansky commented Feb 10, 2017

I am trying to assign an attribute to the newest created element.
Here's my code:

`$('.mt-repeater').each(function(){
$(this).repeater({
isFirstItemUndeletable: true,

				show: function () {
					$(this).slideDown();

					$.ajax({
						type: "POST",
						url: ADMINURL + "/ajax/shop.couriers.php",
						dataType: 'html',
						data: {
							'generate_courier_post_zone_number': 1
						},
						cache: false,
						success: function (res) {
							if(res) {
								$(this).removeAttr('data-unicue-id');
								$(this).attr('data-unicue-id', res);
							}
						}
					});

					//Init other plugins if have here
				},

				hide: function (deleteElement) {
					if(confirm(_SHOP_COURIER_DEL_CONFIRM)) {

						var del_id = $(this).data('id');

						$.ajax({
							type: "POST",
							url: ADMINURL + "/ajax/shop.couriers.php",
							dataType: 'json',
							data: {
								'deleteCourier': del_id
							},
							success: function (res) {
								$(this).slideUp(deleteElement);
							}
						});
					}
				},

				ready: function (setIndexes) {

				}

			});
		});`
@Kristiansky
Copy link
Author

The following code doesn't change the elements attributes:
$(this).removeAttr('data-unicue-id'); $(this).attr('data-unicue-id', res);
Instead, they have the same ids. Any suggestions?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant