Javascript ( jQuery ) Error: SyntaxError: missing ) after argument list

Posted by Obmerk Kronen on Stack Overflow See other posts from Stack Overflow or by Obmerk Kronen
Published on 2013-11-13T15:49:21Z Indexed on 2013/11/13 15:53 UTC
Read the original article Hit count: 132

Filed under:
|
|

I have the simplest function :

jQuery(document).ajaxSuccess(function(e, xhr, settings) {
   var widget_id_base = '099_cf_samurai_widget';

   if(settings.data.search('action=save-widget') != -1 &&
        settings.data.search('id_base=' + widget_id_base) != -1) {
        // alert(\'yay!'\);
         my_function_chosen_099();
   }

}); 

function my_function_chosen_099(){
   jQuery(".chzn-select").chosen();
}

which works just fine , but When I add the width Parameter like so :

function my_function_chosen_k99(){
   jQuery(".chzn-select").chosen(width:'95%');
}

it gives me an error of:

    Error: SyntaxError: missing ) after argument list
    Source File: http://localhost/my-path/js/o99.chosen.init.js?ver=k99
    Line: 20, Column: 41
    Source Code:
          jQuery(".chzn-select").chosen(width:"95%"); 
.............................................|

I have tried escaping:

jQuery(".chzn-select").chosen(width:\"95%"\);

and even double

jQuery(".chzn-select").chosen(width:\\"95%"\\);

and in my desperation, even

jQuery(".chzn-select").chosen(
    width:"95%"
);

I checked and rechecked the closing of brackets , and also tried with single quotes ' - but nothing .

There appear to be a lot of similar questions here , but all I saw was escaping problems, ANd I have tried all that I know ..

What is wrong here ?? I assume it is not a simple syntax error - or is it ? ( one which I can not find .. )

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about jQuery