Thought that was your own code.

The thing is you had a semicolon after the parenthesis, ending that
line, so .trigger was not calling any object's method.

trigger('change') triggers the change event for the selected elements.
In that case it's firing the function that has just been bound to the
change event, to start things up.

On Jan 24, 9:57 pm, "Rick Faircloth" <[email protected]> wrote:
> Thanks for the reply, Michael...I caught the missing ), too.
>
> I was wondering, also, what the purpose of the ".trigger('change');" has.
>
> I read that it is used for passing data into the triggered function?
>
> Is my understanding correct?  Can you give me a scenario where
> that is likely to be used?
>
> Rick
>
> > -----Original Message-----
> > From: [email protected] [mailto:[email protected]] On 
> > Behalf Of Michael Geary
> > Sent: Saturday, January 24, 2009 4:28 PM
> > To: [email protected]
> > Subject: [jQuery] Re: Would someone pleae tell me what's wrong with this 
> > syntax?
>
> > Let's try collapsing out the irrelevant code and take out the newlines too:
>
> >     $('#select').change(function() {});.trigger('change');
>
> > Does that make it easier to spot the error?
>
> > -Mike
>
> > > From: Rick Faircloth
>
> > > Hi, all...
>
> > > I keep getting this error from Firebug:
>
> > > syntax error
> > > .trigger('change'); \n
>
> > > for this code:
>
> > >               $(document.ready(function() {
>
> > >                       $('#select').change(function() {
>
> > >                               var newName = '';
> > >                               $('select
> > > option:selected').each(function() {
> > >                                       newname += $(this).text() + ' ';
> > >                               });
>
> > >                       $('#name-div p').text(newName+' [Change]');
> > >                       $('#name-div').fadeIn(500);
>
> > >                       });
>
> > >                       .trigger('change');
> > >               });
>
> > > What's wrong with it?
>
> > > Thanks,
>
> > > Rick

Reply via email to