jquery fancybox iframe change the href value dynamically -


i have button click , want fancybox load whatever content needed depending on checkboxes can check. checkboxes alter value of url needs displayed in iframe within fancybox.

so far can work once, when change again checkboxes see url change on html fancybox won't pop @ all.

here button , link fancybox:

<button type="button" title="compare" class="button">compare</button> <a class="comparefancy" style="display:none;" href="#"></a> 

here happens when click button:

jquery(document).ready(function() {         jquery('.button').click(function(){              var i=0;             var prdstring="";              var prdstring = jquery.map(jquery(':checkbox:checked'), function(n, i){                   return n.value;             }).join(',');              var url='<?php echo mage::geturl('catalog/product_compare/index').'items/'; ?>'+ prdstring + '/uenc/';              jquery('.comparefancy').attr('href', url);//this works time             jquery('.comparefancy').fancybox();  //this work first time             jquery('.comparefancy').trigger('click');        });  }); 

i've tried beforeload method hinted @ on similar answers didn't work me.

edit: after testing more removed display none link , made visible , did following:

  1. checked checkboxes clicked button: first fancybox loads fine
  2. checked other checkboxes, clicked button: link change href fancy won't load.
  3. click link manually , fancybox loads new url

so problem trigger click function then? wtf?

maybe don't need

<a class="comparefancy" style="display:none;" href="#"></a> 

but try firing fancybox manually :

jquery(document).ready(function () {     var = 0; // inside click 0 ... or not     jquery('.button').click(function () {         var prdstring = jquery.map(jquery(':checkbox:checked'), function (n, i) {             return n.value;         }).join(',');         var url = '<?php echo mage::geturl(' catalog / product_compare / index ').' items / '; ?>' + prdstring + '/uenc/';          // open corresponding url in fancybox         jquery.fancybox(url, {             // api options             padding: 0 // example         });      }); }); 

i suggesting fancybox part (moved i variable out of click though). make sure expected url value each checked checkbox parameters passed throught .map() method.


Popular posts from this blog

How to calculate SNR of signals in MATLAB? -

c# - Attempting to upload to FTP: System.Net.WebException: System error -

ios - UISlider customization: how to properly add shadow to custom knob image -