Skip to main content

Bug Tracker

Side navigation

#889 closed feature (wontfix)

Opened January 28, 2007 09:41AM UTC

Closed March 24, 2007 04:01AM UTC

split jquery chain in two parts for matching / not matching conditions

Reported by: tex@off.org Owned by:
Priority: minor Milestone:
Component: core Version:
Keywords: Cc:
Blocked by: Blocking:
Description

There are cases where you want to affect two sets of elements, matching and not matching. here is an example:

<label><input type='radio' name='onOff' value='on'></input>on</label>
<label><input type='radio' name='onOff' value='off'></input>off</label>

calling function either, for lack of a better name. This corresponds to ? : syntax, is there a name for that?

$('#onOff').either(
   '[value=on]',
   function() {
      // this should be passed to each()
      this.checked = true;
      alert( 'checking ' + this.name );
   },
  function() {
     this.checked = false;
  }
);

Anyway, if this sounds interesting to anyone else I'd be happy to send code, or maybe add it as a plugin.

I find myself using this pattern fairly regularly, so.. thought it was worth a request.

Attachments (0)
Change History (2)

Changed January 29, 2007 07:35PM UTC by joern comment:1

description: There are cases where you want to affect two sets of elements, matching and not matching. here is an example:\ \ <label><input type='radio' name='onOff' value='on'></input>on</label>\ <label><input type='radio' name='onOff' value='off'></input>off</label>\ \ calling function either, for lack of a better name. This corresponds to ? : syntax, is there a name for that?\ \ $('#onOff').either(\ '[value=on]',\ function() {\ // this should be passed to each()\ this.checked = true;\ alert( 'checking ' + this.name );\ },\ function() {\ this.checked = false;\ }\ );\ \ Anyway, if this sounds interesting to anyone else I'd be happy to send code, or maybe add it as a plugin.\ I find myself using this pattern fairly regularly, so.. thought it was worth a request.There are cases where you want to affect two sets of elements, matching and not matching. here is an example:\ \ {{{\ <label><input type='radio' name='onOff' value='on'></input>on</label>\ <label><input type='radio' name='onOff' value='off'></input>off</label>\ }}}\ \ calling function either, for lack of a better name. This corresponds to ? : syntax, is there a name for that?\ \ {{{\ $('#onOff').either(\ '[value=on]',\ function() {\ // this should be passed to each()\ this.checked = true;\ alert( 'checking ' + this.name );\ },\ function() {\ this.checked = false;\ }\ );\ }}}\ \ Anyway, if this sounds interesting to anyone else I'd be happy to send code, or maybe add it as a plugin.\ I find myself using this pattern fairly regularly, so.. thought it was worth a request.

Changed March 24, 2007 04:01AM UTC by john comment:2

resolution: → wontfix
status: newclosed

This was brought up before, in the form of an if/else plugin. We opted not to include. However, I'm sure having a simple .either() plugin would be very useful to a number of people.