Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><strong>Assumptions:</strong><br/></p> <ol> <li>It looks like you are using the slidepanel plugin at <a href="http://jsfiddle.net/aaronbennett/kP79H/" rel="nofollow">http://plugins.jquery.com/project/slidePanel</a></li> <li>You want all other panels to close that do not belong to the current trigger, while maintaining the ability to toggle the current trigger's panel.</li> </ol> <p><strong>THE SOLUTION</strong><br/> You can add a small change to the plugin that will hide all panels before executing slidePanel() to show the intended panel.</p> <pre><code>if (!panel.is(':visible')) { $('.panel').hide(opts.speed);$('.trigger').removeClass('active'); } </code></pre> <p>The entire plugin has been included below to show where you should make the change (look for comment that says "STACKOVERFLOW EDIT"). See the <strong><a href="http://jsfiddle.net/aaronbennett/kP79H/" rel="nofollow">working example</a></strong> at jsfiddle using markup from the plugin demo page.</p> <pre><code>/* jQuery slidePanel plugin * Examples and documentation at: http://www.jqeasy.com/ * Version: 1.0 (22/03/2010) * No license. Use it however you want. Just keep this notice included. * Requires: jQuery v1.3+ * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR * OTHER DEALINGS IN THE SOFTWARE. */ (function($){ $.fn.slidePanel = function(opts) { opts = $.extend({ triggerName: '#trigger', position: 'absolute', triggerTopPos: '80px', panelTopPos: '50px', panelOpacity: 0.9, speed: 'fast', ajax: false, ajaxSource: null, clickOutsideToClose: true }, opts || {}); var panel = this; var trigger = $(opts.triggerName); var isIE6 = $.browser.msie &amp;&amp; $.browser.version=="6.0" // ie6 doesn't like fixed position if(isIE6) { opts.position = 'absolute' } // set css properties for trigger and panel trigger.css('position',opts.position) trigger.css('top',opts.triggerTopPos); panel.css('position',opts.position) panel.css('top',opts.panelTopPos); panel.css('filter', 'alpha(opacity='+(opts.panelOpacity*100)+')'); panel.css('opacity', opts.panelOpacity); // triggerName mousedown event trigger.attr( "href", "javascript:void(0)" ).mousedown(function() { // load default content if ajax is false // STACKOVERFLOW EDIT: http://stackoverflow.com/questions/2551217/jquery-select-all-elements-of-a-given-class-except-for-a-particular-id // hide all panels and reset all trigger classes. first check if visible to allow toggle to function if (!panel.is(':visible')) { $('.panel').hide(opts.speed);$('.trigger').removeClass('active'); } if (!opts.ajax) { panel.toggle(opts.speed); trigger.toggleClass("active"); }; // load ajax data if ajax is true or throw error if no ajaxSource defined if (opts.ajax &amp;&amp; opts.ajaxSource!=null) { // fetch data ONLY when panel is hidden... // otherwise it fetches data when the panel is closing if (!panel.is(':visible')) { panel.load(opts.ajaxSource, function(response, status, xhr) { // if the ajax source wasn't loaded properly if (status !== "success") { var msg = "&lt;p&gt;Sorry, but there was an error loading the document.&lt;/p&gt;"; panel.html(msg); }; // this is part of the .load() callback so it fills the panel BEFORE opening it panel.toggle(opts.speed); }); } else { panel.toggle(opts.speed); }; trigger.toggleClass("active"); } else if (opts.ajax &amp;&amp; opts.ajaxSource==null) { alert('You must define an ajaxSource to use Ajax.'); }; return false; }); if (opts.clickOutsideToClose) { // bind the 'mousedown' event to the document so we can close panel without having to click triggerName $(document).bind('mousedown',function(){panel.hide(opts.speed);trigger.removeClass('active');}); // don't close panel when clicking inside it panel.bind('mousedown',function(e){e.stopPropagation();}); }; }; })(jQuery); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload