Search code examples
jquerypositionoffsetjquery-toolscss-position

Position jQuery Tools overlay next to trigger


I want to have multiple overlays with multiple triggers all with the same class opener with jQuery Tools and apple effect. How can I position the overlays next to their triggers? I have tried

$('button.opener').click(function() {
      var positionx = $('#' + this.id).offset().left;
      example("#item").overlay({
 left: positionx,

but it only works the first time it is opened. would really, really appreciate the any help. here is a jsfiddle http://jsfiddle.net/FHKVW/ thanks.


Solution

  • You have to set the left position outside of the initial config. For some reason, the re-running of .overlay doesn't override the config settings. This should work:

    var example = jQuery.noConflict();
    $('button.opener').click(function () {
        var positionx = $('#' + this.id).offset().left;
        example("#item").overlay({
            left: positionx,
            top: 100,
            closeOnClick: false,
            load: false,
            effect: 'apple',
            speed: 1000,
            oneInstance: false,
            fixed: false,
        });
        //add this line
        example('#item').overlay().getConf().left = positionx;
    
       (example('#item').overlay().isOpened() == true) ? example('#item').overlay().close() : example('#item').overlay().load();
    });