Search code examples
jquerymodal-dialogcolorboxhtml-content-extraction

load content from page.. by the href of a class... inside a modal


Trying to do the following: my page has got a lot of div's with 's to open modalboxes (colorbox). The pages that these links open got an id="mainColumn". Content need only to be loaded from this id.

I've got this:

<div>                       
<a href="includes/page_1.html" class="modal"></a>
</div>

<div>                       
<a href="includes/page_2.html" class="modal"></a>
</div>

<div>                       
<a href="includes/page_3.html" class="modal"></a>
</div>


 $(".modal").colorbox({
    width:900,
    href: $(".modal").attr('href') + " #mainColumn"
    });

It works great... Except that the href's of al of the 's change into the first one...

So includes/page_3.html changes into includes/page_1.html or in other words: All of the modalboxes show the same content...

any help would appreciated, thanks


Solution

  • $(".pop").each(function() {
      var el = $(this);
      el.colorbox({
        href: el.attr('href') + " #mainColumn"
      });
    });