I'm trying to improve a module I wrote which uses jqeury snippet

// Select all submit buttons and siblings
$(document).ready(function() {
  $('input:submit').click(function() {
      $(this).siblings('input:submit').hide();            
      $(this).hide();      
      $('$message').insertAfter(this);
  })  
})

I want to filter/exclude not to choose elements that are children of specific class/id

<div id='one'>
   <input name="op" id="edit-1-1" value="Submit 1-1" class="form-submit" type="submit">
   <input name="op" id="edit-1-2" value="Submit 1-2" class="form-submit" type="submit">
</div>
<div id='two'>
   <input name="op" id="edit-2" value="Submit 2-1" class="form-submit" type="submit">
   <input name="op" id="edit-2" value="Submit 2-2" class="form-submit" type="submit">
</div>

For example I want NOT to choose submit buttons that are children of #one

See original issue #432988: Conflicts with shoutbox module

Any ideas?

Comments

jaypan’s picture

Contact me to contract me for D7 -> D10/11 migrations.

optalgin’s picture

Thanks

I tried to play with :not selector but I still don't get the result I want

Select all submit button since, non of them are #one, only the "father" div container

$('input:submit:not(#one)')

This works, and select a specific button, but this is not what I am looking for

$('input:submit:not(#edit-1-1)')

I think the logic should be something like subtraction between sets

$('input:submit') - $('#one *')
  = { edit-1-1, edit-1-2, edit-2-1, edit-2-2 } - { edit-1-1, edit-1-2, ... } 
  = { edit-2-1, edit-2-2 } 

Is there a way to do it?
I don't see a reason why this should be complicated

The main reason I need this is to disable the feature for specific css containers
such as shout-box etc..

optalgin’s picture

Ohhh.. this is a hard nut

I can select submit buttons of certain div

$('div #shoutbox-body input:submit')

But I cannot find a way to select all submit buttons that are NOT in this div...
This selector is the best I could find, but it doesn't work ...

$('input:submit:not(div #shoutbox-body input:submit)')

Anyone?

jaypan’s picture

I just played with that for about 15 minutes, but I couldn't figure it out. Maybe try http://jqueryhelp.com/ - they are soon to become the official jquery help forum.

If you find an answer, can you post it here? I'm curious.

Contact me to contract me for D7 -> D10/11 migrations.