[jQuery] Form plugin: possible to alter the form after a submit?
I'm using the form plugin and want do to things with the form doing the ajax submit, after the submit has happened. Unlike the option before:, after: doesn't seem to pass the jQuery object. Any way around this? Simplified example using ajaxForm() : var options = { after: function(data){ $(data).insertBefore(THE FORM); }; $(form.severalForms).ajaxForm(options); Thanks, Anders ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] Form plugin: possible to alter the form after a submit?
I'm using the form plugin and want do to things with the form doing the ajax submit, after the submit has happened. Unlike the option before:, after: doesn't seem to pass the jQuery object. Any way around this? It's a little bit asymmetrical because ajaxForm depends on jQuery.ajax for some of the work. The ajaxForm after function is the jQuery.ajax success function, renamed. So it gets the xmlhttp data and a status code, that's it. You should be able to use a closure to get what you want--untested: var options = { ... }; $(form.severalForms).each(function(formElement){ $(this).ajaxForm($.extend(options, { after: function(data, status) { $(formElement).insertBefore(ajax complete); } }); }); ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] Form plugin: possible to alter the form after a submit?
You should be able to use a closure to get what you want--untested: Thanks, Dave. It's true, the 'after' callback is invoked directly from $.ajax so it doesn't have the context of the form. A closure should work fine though - a simple example (tested): $('form').each(function() { var theForm = this; var options = { after: function() { alert(theForm.id) } }; $(this).ajaxForm(options); }); ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] Form plugin: possible to alter the form after a submit?
var options = { ... }; $(form.severalForms).each(function(formElement){ $(this).ajaxForm($.extend(options, { after: function(data, status) { $(formElement).insertBefore(ajax complete); } }); }); Thanks for the closure tip. I come up with the code below, but your example might be cleaner. var formElement; var options = { // Store the current form so it can be used in after: before: function(data, object) {formElement = object;}, after: function(data){ $(data).insertBefore(formElement); }; $(form.severalForms).ajaxForm(options); ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] Form plugin: possible to alter the form after a submit?
Thanks for the closure tip. I come up with the code below, but your example might be cleaner. That will work as long as you don't have multiple forms submitting concurrently. ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] Is this possible?
$([EMAIL PROTECTED]'enabled']).click(function() { ... });See the jQuery docs for more options.BlairOn 11/7/06, Christopher Jordan [EMAIL PROTECTED] wrote: Hi folks, I have a table that represents a calendar. The user will be able to select multiple dates from the calendar, but cannot select dates in the past. I've written this code before using all _javascript_ and what I did was add several additional pieces of data to the td tag other than ID or CLASS. I added state, index, status and a few others. I accessed these through f.calendarid.state... that kind of thing. So I'm wanting to apply an event (probably several: click, mouseover, mouseout) to only those td tags that have their state set to enabled. Not to *all* tds and not even to all tds with a certain class. ID alone won't work. Is there a way to do this using jQuery? Something like: $(td status).click()... or whatever. Thanks, Chris ___jQuery mailing listdiscuss@jquery.com http://jquery.com/discuss/ ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] Is this possible?
I suggest starting off with a naked calendar, just the dates. then jquery a class on the present future dates. then jquery those with your new class to have all the clicks an hovers you want. no special attributes required. On 11/6/06, Christopher Jordan [EMAIL PROTECTED] wrote: Hi folks, I have a table that represents a calendar. The user will be able to select multiple dates from the calendar, but cannot select dates in the past. I've written this code before using all JavaScript and what I did was add several additional pieces of data to the td tag other than ID or CLASS. I added state, index, status and a few others. I accessed these through f.calendarid.state... that kind of thing. So I'm wanting to apply an event (probably several: click, mouseover, mouseout) to only those td tags that have their state set to enabled. Not to *all* tds and not even to all tds with a certain class. ID alone won't work. Is there a way to do this using jQuery? Something like: $(td status).click()... or whatever. Thanks, Chris ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/ -- Ⓙⓐⓚⓔ - יעקב ʝǡǩȩ ᎫᎪᏦᎬ ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] Is this possible?
Chris, I haven't tried it but would $([EMAIL PROTECTED]'enabled']).click() -Steve W Christopher Jordan wrote: Hi folks, I have a table that represents a calendar. The user will be able to select multiple dates from the calendar, but cannot select dates in the past. I've written this code before using all JavaScript and what I did was add several additional pieces of data to the td tag other than ID or CLASS. I added state, index, status and a few others. I accessed these through f.calendarid.state... that kind of thing. So I'm wanting to apply an event (probably several: click, mouseover, mouseout) to only those td tags that have their state set to enabled. Not to *all* tds and not even to all tds with a certain class. ID alone won't work. Is there a way to do this using jQuery? Something like: $(td status).click()... or whatever. Thanks, Chris ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/ ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] Is this possible?
Check out the date plugin. I cant link it now, but a quick google for jquery date picker should find it. On 11/6/06, Christopher Jordan [EMAIL PROTECTED] wrote: Hi folks, I have a table that represents a calendar. The user will be able to select multiple dates from the calendar, but cannot select dates in the past. I've written this code before using all JavaScript and what I did was add several additional pieces of data to the td tag other than ID or CLASS. I added state, index, status and a few others. I accessed these through f.calendarid.state... that kind of thing. So I'm wanting to apply an event (probably several: click, mouseover, mouseout) to only those td tags that have their state set to enabled. Not to *all* tds and not even to all tds with a certain class. ID alone won't work. Is there a way to do this using jQuery? Something like: $(td status).click()... or whatever. Thanks, Chris ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] Is this possible?
Christopher Jordan schrieb: Hi folks, I have a table that represents a calendar. The user will be able to select multiple dates from the calendar, but cannot select dates in the past. I've written this code before using all JavaScript and what I did was add several additional pieces of data to the td tag other than ID or CLASS. I added state, index, status and a few others. I accessed these through f.calendarid.state... that kind of thing. So I'm wanting to apply an event (probably several: click, mouseover, mouseout) to only those td tags that have their state set to enabled. Not to *all* tds and not even to all tds with a certain class. ID alone won't work. Is there a way to do this using jQuery? Something like: $(td status).click()... or whatever. Thanks, Chris Hi Christopher, this could work: $('td').each(function() { if (this.status == 'enabled') $(this).click(function() { // do something }); }); -- Klaus ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] Is this possible?
I need more than a date picker... Otherwise I might have used that. Thanks Chris Matt Stith wrote: Check out the date plugin. I cant link it now, but a quick google for "jquery date picker" should find it. On 11/6/06, Christopher Jordan [EMAIL PROTECTED] wrote: Hi folks, I have a table that represents a calendar. The user will be able to select multiple dates from the calendar, but cannot select dates in the past. I've written this code before using all _javascript_ and what I did was add several additional pieces of data to the td tag other than ID or CLASS. I added "state", "index", "status" and a few others. I accessed these through f.calendarid.state... that kind of thing. So I'm wanting to apply an event (probably several: click, mouseover, mouseout) to only those td tags that have their state set to "enabled". Not to *all* tds and not even to all tds with a certain class. ID alone won't work. Is there a way to do this using jQuery? Something like: $("td" status).click()... or whatever. Thanks, Chris ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/ ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] Is this possible?
Thanks Klaus! How does this syntax differ from other suggested syntax: $("[EMAIL PROTECTED]'enabled']").click() I'm curiout which is preferred, or faster. They both look clean enough to me. Chris Klaus Hartl wrote: Christopher Jordan schrieb: Hi folks, I have a table that represents a calendar. The user will be able to select multiple dates from the calendar, but cannot select dates in the past. I've written this code before using all _javascript_ and what I did was add several additional pieces of data to the td tag other than ID or CLASS. I added "state", "index", "status" and a few others. I accessed these through f.calendarid.state... that kind of thing. So I'm wanting to apply an event (probably several: click, mouseover, mouseout) to only those td tags that have their state set to "enabled". Not to *all* tds and not even to all tds with a certain class. ID alone won't work. Is there a way to do this using jQuery? Something like: $("td" status).click()... or whatever. Thanks, Chris Hi Christopher, this could work: $('td').each(function() { if (this.status == 'enabled') $(this).click(function() { // do something }); }); -- Klaus ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/ ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] Is this possible?
Hmm... I dunno. Maybe, I'm sure it could work, but I'm under a time crunch. Maybe when the pressure is off, I can look at doing something like this. I'm still a noob with this jQuery stuff. I can do some things, but you guys mostly put me to shame. :o) Chris wrote: I suggest starting off with a naked calendar, just the dates. then jquery a class on the present future dates. then jquery those with your new class to have all the clicks an hovers you want. no special attributes required. On 11/6/06, Christopher Jordan [EMAIL PROTECTED] wrote: Hi folks, I have a table that represents a calendar. The user will be able to select multiple dates from the calendar, but cannot select dates in the past. I've written this code before using all _javascript_ and what I did was add several additional pieces of data to the td tag other than ID or CLASS. I added "state", "index", "status" and a few others. I accessed these through f.calendarid.state... that kind of thing. So I'm wanting to apply an event (probably several: click, mouseover, mouseout) to only those td tags that have their state set to "enabled". Not to *all* tds and not even to all tds with a certain class. ID alone won't work. Is there a way to do this using jQuery? Something like: $("td" status).click()... or whatever. Thanks, Chris ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/ No virus found in this incoming message. Checked by AVG Free Edition. Version: 7.5.430 / Virus Database: 268.13.28/518 - Release Date: 11/4/2006 5:30 PM ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] Is this possible?
Matt, I've rethought my comment here. I don't really know what the jQuery date picker's abilities/limitations are. Like I told Jake, I'm under a bit of a time crunch and I need to try and stick to stuff I know. Who knows? The date picker may be the answer to my prayers. I'll google it and give it a quick look. If it doesn't work for this, it would definitely work other places I'm sure. I've got date picker stuff all over my app. I *think* this one is just a bit more specialized. First off there are three calendars, and the user can choose to go forward or backward one or three months at a time. Anyway, I just thought it sounded like I dismissed your idea with out thinking about it first. I appreciate the help. :o) Chris Christopher Jordan wrote: I need more than a date picker... Otherwise I might have used that. Thanks Chris Matt Stith wrote: Check out the date plugin. I cant link it now, but a quick google for "jquery date picker" should find it. On 11/6/06, Christopher Jordan [EMAIL PROTECTED] wrote: Hi folks, I have a table that represents a calendar. The user will be able to select multiple dates from the calendar, but cannot select dates in the past. I've written this code before using all _javascript_ and what I did was add several additional pieces of data to the td tag other than ID or CLASS. I added "state", "index", "status" and a few others. I accessed these through f.calendarid.state... that kind of thing. So I'm wanting to apply an event (probably several: click, mouseover, mouseout) to only those td tags that have their state set to "enabled". Not to *all* tds and not even to all tds with a certain class. ID alone won't work. Is there a way to do this using jQuery? Something like: $("td" status).click()... or whatever. Thanks, Chris ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/ ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/ No virus found in this incoming message. Checked by AVG Free Edition. Version: 7.5.430 / Virus Database: 268.13.28/518 - Release Date: 11/4/2006 5:30 PM ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] Is this possible?
They are more or less equivalent, but using the jQuery select syntax is standard and probably easier to read.BlairOn 11/7/06, Christopher Jordan [EMAIL PROTECTED] wrote: Thanks Klaus! How does this syntax differ from other suggested syntax: $([EMAIL PROTECTED]'enabled']).click()I'm curiout which is preferred, or faster. They both look clean enough to me.Chris Klaus Hartl wrote: Christopher Jordan schrieb: Hi folks,I have a table that represents a calendar. The user will be able to select multiple dates from the calendar, but cannot select dates in the past. I've written this code before using all _javascript_ and what I did was add several additional pieces of data to the td tag other than ID or CLASS. I added state, index, status and a few others. I accessed these through f.calendarid.state... that kind of thing. So I'm wanting to apply an event (probably several: click, mouseover, mouseout) to only those td tags that have their state set to enabled. Not to *all* tds and not even to all tds with a certain class. ID alone won't work. Is there a way to do this using jQuery? Something like: $(td status).click()... or whatever.Thanks,Chris Hi Christopher, this could work:$('td').each(function() { if (this.status == 'enabled') $(this).click(function() { // do something });}); -- Klaus___jQuery mailing listdiscuss@jquery.com http://jquery.com/discuss/ ___jQuery mailing listdiscuss@jquery.com http://jquery.com/discuss/ ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] Is this possible?
Thanks Blair. So your suggestion of using $("[EMAIL PROTECTED]'enabled']").click() is the selection syntax? Hmm... I'm gonna look that up. Thanks! :o) Chris Blair McKenzie wrote: They are more or less equivalent, but using the jQuery select syntax is standard and probably easier to read. Blair On 11/7/06, Christopher Jordan [EMAIL PROTECTED] wrote: Thanks Klaus! How does this syntax differ from other suggested syntax: $("[EMAIL PROTECTED]'enabled']").click() I'm curiout which is preferred, or faster. They both look clean enough to me. Chris Klaus Hartl wrote: Christopher Jordan schrieb: Hi folks, I have a table that represents a calendar. The user will be able to select multiple dates from the calendar, but cannot select dates in the past. I've written this code before using all _javascript_ and what I did was add several additional pieces of data to the td tag other than ID or CLASS. I added "state", "index", "status" and a few others. I accessed these through f.calendarid.state... that kind of thing. So I'm wanting to apply an event (probably several: click, mouseover, mouseout) to only those td tags that have their state set to "enabled". Not to *all* tds and not even to all tds with a certain class. ID alone won't work. Is there a way to do this using jQuery? Something like: $("td" status).click()... or whatever. Thanks, Chris Hi Christopher, this could work: $('td').each(function() { if (this.status == 'enabled') $(this).click(function() { // do something }); }); -- Klaus ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/ ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/ ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/ No virus found in this incoming message. Checked by AVG Free Edition. Version: 7.5.430 / Virus Database: 268.13.28/518 - Release Date: 11/4/2006 5:30 PM ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] Is this possible?
Chris, I think you would need to test for performance differences unless John or one of the other guys with more clue have some insight. This works by creating a jquery collection of all td objects and using each to iterate through them, then uses the if to filter them. $('td').each(function() { if (this.status == 'enabled') $(this).click(function() { // do something }); }); Where as: $([EMAIL PROTECTED]'enabled']).click() uses the xpath syntax to create a collection of just those td's that have the attribute state='enabled' set on them, then applies the click() method to each of them. The first is probably a little more readable if you are new to jquery and requires you to write more code. The later is probably more jQuery-ish and I guessing it is a little faster, but I have not done any testing and really have no facts to support the guess. -Steve Christopher Jordan wrote: Thanks Klaus! How does this syntax differ from other suggested syntax: $([EMAIL PROTECTED]'enabled']).click() I'm curiout which is preferred, or faster. They both look clean enough to me. Chris Klaus Hartl wrote: Christopher Jordan schrieb: Hi folks, I have a table that represents a calendar. The user will be able to select multiple dates from the calendar, but cannot select dates in the past. I've written this code before using all JavaScript and what I did was add several additional pieces of data to the td tag other than ID or CLASS. I added state, index, status and a few others. I accessed these through f.calendarid.state... that kind of thing. So I'm wanting to apply an event (probably several: click, mouseover, mouseout) to only those td tags that have their state set to enabled. Not to *all* tds and not even to all tds with a certain class. ID alone won't work. Is there a way to do this using jQuery? Something like: $(td status).click()... or whatever. Thanks, Chris Hi Christopher, this could work: $('td').each(function() { if (this.status == 'enabled') $(this).click(function() { // do something }); }); -- Klaus ___ jQuery mailing list discuss@jquery.com mailto:discuss@jquery.com http://jquery.com/discuss/ ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/ ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] Is this possible?
Steve, That's a great explanation of the difference between these two methods. Thanks so much! I'll probably use the first method to begin with. It is easier for me to read, but that's probably because of my lack of understanding anything about xpath. Something else I'll have to do some reading on. Thanks again! :o) Chris Stephen Woodbridge wrote: Chris, I think you would need to test for performance differences unless John or one of the other guys with more clue have some insight. This works by creating a jquery collection of all td objects and using each to iterate through them, then uses the if to filter them. $('td').each(function() { if (this.status == 'enabled') $(this).click(function() { // do something }); }); Where as: $("[EMAIL PROTECTED]'enabled']").click() uses the xpath syntax to create a collection of just those td's that have the attribute state='enabled' set on them, then applies the click() method to each of them. The first is probably a little more readable if you are new to jquery and requires you to write more code. The later is probably more jQuery-ish and I guessing it is a little faster, but I have not done any testing and really have no facts to support the guess. -Steve Christopher Jordan wrote: Thanks Klaus! How does this syntax differ from other suggested syntax: $("[EMAIL PROTECTED]'enabled']").click() I'm curiout which is preferred, or faster. They both look clean enough to me. Chris Klaus Hartl wrote: Christopher Jordan schrieb: Hi folks, I have a table that represents a calendar. The user will be able to select multiple dates from the calendar, but cannot select dates in the past. I've written this code before using all _javascript_ and what I did was add several additional pieces of data to the td tag other than ID or CLASS. I added "state", "index", "status" and a few others. I accessed these through f.calendarid.state... that kind of thing. So I'm wanting to apply an event (probably several: click, mouseover, mouseout) to only those td tags that have their state set to "enabled". Not to *all* tds and not even to all tds with a certain class. ID alone won't work. Is there a way to do this using jQuery? Something like: $("td" status).click()... or whatever. Thanks, Chris Hi Christopher, this could work: $('td').each(function() { if (this.status == 'enabled') $(this).click(function() { // do something }); }); -- Klaus ___ jQuery mailing list discuss@jquery.com mailto:discuss@jquery.com http://jquery.com/discuss/ ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/ ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/ ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] Is this possible?
Blair McKenzie schrieb: They are more or less equivalent, but using the jQuery select syntax is standard and probably easier to read. I was assuming that expando properties (the property is attached to the DOM element) were used instead of real attributes... -- Klaus ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] Is this possible?
I don't think it makes any difference. jQuery accesses both transparently.BlairOn 11/7/06, Klaus Hartl [EMAIL PROTECTED] wrote:Blair McKenzie schrieb: They are more or less equivalent, but using the jQuery select syntax is standard and probably easier to read.I was assuming that expando properties (the property is attached to theDOM element) were used instead of real attributes...-- Klaus___ jQuery mailing listdiscuss@jquery.comhttp://jquery.com/discuss/ ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/