Nikul
Nikul

Reputation: 495

getting js error "expected identifier" while using internet explorer

I have code for export PDF, it is working fine for all browsers but when I use it in IE it gives me a JS error like expected identifier for this line $.fn.yiiGridView.export();.

Can anyone please tell me how I can resolve this issue.

$('#export-button').on('click', function() {       
    $.fn.yiiGridView.export();
});

Upvotes: 0

Views: 1401

Answers (1)

trincot
trincot

Reputation: 350147

export is a reserved word in ES6, so use the bracket notation instead:

$('#export-button').on('click', function() {       
    $.fn.yiiGridView['export']();
});

If you have created that function yourself, then it is better to use a different name, like myexport:

$.fn.yiiGridView.myexport = function () { .... };

and then:

$('#export-button').on('click', function() {       
    $.fn.yiiGridView.myexport();
});

Upvotes: 2

Related Questions