Prefixing each GET parameter with component name sucks

Notice: This thread is very old.
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 (2015-10-31 20:12)

Felix
Nette Core | 1186
+
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 :(