trigger() function not pass extraParameters when trigger click event of a radio element (Only jQuery 3.2.0) #3579

Closed
GrayYoung opened this Issue Mar 20, 2017 · 9 comments

Comments

Projects
None yet
4 participants
$(document).on('click', '#tab-type .list-choice :radio', function(event, isSimulated) {
	// Prescription Type
	var pstType = $(this).val(), $colADD = PS.$tabs.eq(3).find('.col-add');

	if(PS.isSingleVision(pstType)) {
		$colADD.find('.form-control').val(PS.data.ADD.defaultValue).valid();
		$colADD.addClass('hidden');
	} else {
		$colADD.removeClass('hidden');
	}
	if(isSimulated !== true) { 
		if(PS.isNonRX(pstType)) {
			PS.$tabs.eq(3).removeClass('active');
		} else {
			// VWC-1075
			PS.$tabs.eq(3).addClass('active').find(':input:visible:first').focus();

			$modal.scrollTop($modal.scrollTop() + PS.$tabs.eq(3).offset().top);
		}
	}
	PS.data.prescriptionType = pstType;
	$btnNext.removeClass('hidden');
});

// In another function
PS.$tabs.eq(2).find(':radio').filter(function() {
	if(this.value === data.prescriptionType) {
		return true;
	}
	if($(this).closest('label').text().trim() === data.prescriptionType) {
		return true;
	}

	return false;
}).trigger('click', [true]);

isSimulated is undefined, it should be true.

Member

mgol commented Mar 20, 2017

Could you create a test case without external libraries on https://jsfiddle.net or https://jsbin.com?

Member

mgol commented Mar 20, 2017

...actually, this seems like https://bugs.jquery.com/ticket/13353 (also relevant: #1741). I'm closing this one as a duplicate; I assume your issue is not isolated to jQuery 3.2.0 but also happens in older versions.

@mgol mgol closed this Mar 20, 2017

But when I switch the version to 3.1.1, the code work fine.

Member

mgol commented Mar 20, 2017

OK, please provide a test case on https://jsfiddle.net or https://jsbin.com then and we'll have a look.

@mgol mgol reopened this Mar 20, 2017

@mgol mgol added the Needs info label Mar 20, 2017

https://jsfiddle.net/kzg5o5pa/5/

I finally have done the test case, trigger function with passing extraParameters not work on radio element, but button element. It is so strange.
Tested the case use jQuery 3.2.0 and jQuery 3.1.1, only not work when use jQuery 3.2.0 .

@GrayYoung GrayYoung changed the title from trigger() function not pass extraParameters when update jQuery into 3.2.0 to trigger() function not pass extraParameters when trigger click event of a radio element (Only jQuery 3.2.0) Mar 20, 2017

Member

mgol commented Mar 20, 2017

I can confirm the behavior. A simplified test case: https://jsfiddle.net/kzg5o5pa/7/.

This is a regression from 3.1.1.

Thank you!

@mgol mgol added Blocker Bug Event and removed Needs info labels Mar 20, 2017

@mgol mgol added this to the 3.2.1 milestone Mar 20, 2017

Member

mgol commented Mar 20, 2017

The regression was introduced in b442aba.

@mgol mgol added the Needs review label Mar 20, 2017

Member

gibson042 commented Mar 20, 2017

The regression was introduced in b442aba.

And as such, is actually a "fix" to a consistently-broken state.

Owner

timmywil commented Mar 20, 2017

We're going to back out this change and take closer look at #1367 for 3.3.

@timmywil timmywil removed the Needs review label Mar 20, 2017

@timmywil timmywil closed this in a6b0705 Mar 20, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment