Obmerk Kronen
Obmerk Kronen

Reputation: 15949

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

I have a simple javascript/jquery 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) {
         my_function_chosen_o99();
   }
}); 

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

Which works correctly, but when I add the width parameter:

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

It gives me an error:

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%"); 
.............................................|

What is wrong with this code?

Upvotes: 1

Views: 10004

Answers (1)

Arun P Johny
Arun P Johny

Reputation: 388316

You need to pass an object as the argument(within {})

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

Upvotes: 9

Related Questions