Reputation: 16420
This handler doesn't like the $page parameter in the eval function, getting error "missing ] after element list" is there anyway to pass this parameter through?
$('div[data-role="page"]').live('pageinit pagebeforeshow pageshow pagebeforehide pagehide', function (event, ui) {
var $page = $(this);
var type = event.type.replace('page', 'Page').replace('init', 'Init').replace('before', 'Before').replace('show', 'Show').replace('hide', 'Hide');
eval('Controller.Method.' + type + '(' + $page + ')');
});
Upvotes: 0
Views: 377
Reputation: 154828
You're forcing $page
to be part of a string, which doesn't quite work because it's a jQuery object. The string will be [object Object]
because there is no better string representation for a jQuery object.
This is exactly a case in which to avoid using eval
. This should work, and is cleaner and safer:
Controller.Method[type]($page);
Upvotes: 1