Prefixing each GET parameter with component name sucks

meridius
Member | 34
+
0
-

I have a component with handle function:

public function handleBadgeSearch($q, $page, $badgeType) {
	/* some code */
}

to serve AJAX requests from presenter's template js code:

select.show().select2({
	tags: true,
	ajax: {
		delay: 250,
		cache: true,
		url: {link autocompleteComponent:badgeSearch!},
		data: function(params) {
			return { {* FIXME prefixing each GET parameter with component name sucks! *}
				"autocompleteComponent-q": params.term,
				"autocompleteComponent-page": params.page,
				"autocompleteComponent-badgeType": badgeType
			};
		},
		processResults: function(data, page) {
			return {
				results: data.items
			};
		}
	}
});

I can't get to any of the GET parameters unless I prefix them with component name.
This gets more complicated with every added (nested) layer of component demanding its prefix.

Is there any other way?

Last edited by meridius (31. 10. 2015 20:12)

Felix
Moderator | 1279
+
0
-

Nope. It's needed to separate parameters for more components. =/ I don't like it neither.

meridius
Member | 34
+
0
-

Thank you. I really hoped there would be some way around it. Shame :(

RSS feed Topic closed