> it's firing the function that has just been bound to the > change event, to start things up.
You mean, it's running the function right before it that I set up to run on the change of the select value? If so, what would be a scenario where I'd want to start the function using 'trigger' without the 'change' to the select (or any other event) occurring? Thanks, Rick > -----Original Message----- > From: [email protected] [mailto:[email protected]] On > Behalf Of Ricardo Tomasi > Sent: Sunday, January 25, 2009 1:24 AM > To: jQuery (English) > Subject: [jQuery] Re: Would someone pleae tell me what's wrong with this > syntax? > > > 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

