Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript

bug: colorbox.js plugin pops-up in parent tab and in a new tab as well

Hi I need your help

I'm trying to build a web app using lungo frimework: http://lungo.tapquo.com/ and colorbox.js pluggin: http://www.jacklmoore.com/colorbox/

I would like to build a button that when is clicked, it's pops-up a pdf file on top of it (in parent tab).

the problem is that now it works fine but opens the 'pdf' file also in a new tab window..

Here are the code:

<article id="main-article" class="active list scroll" >               
    <ul id="bills" class="colorbox">
        <li class="selectable thumb">
            <img src="img/image1.png">
            <a href="https://docs.google.com/viewer?   url=http://s3.amazonaws.com/USACWeb/forms/code_of_conduct.pdf&embedded=true" 
               class="button small red right" target="_blank" 
               data-label="show"><abbr>show</abbr></a>
            <small>03/07/2013</small>
        </li>
    </ul>
</article>


$.colorbox").on("click", "a", function (){
(
" $.colorbox({
his).attr('href'),
      iframe: 
      href: $(
ttrue,
      width: "98%",
      height: "98%"
 to
  });
 });
 if (top.location != self.location)
 {p.location = self.location.href;
 }

Please help or recomand maybe for other plugin and instructions how to avoid the bug I'm having...

Thanks :) Daniel.T

1 Answer

It's a Web application that will eventually run on mobile devices and tablets..

Andrew Chalkley
Andrew Chalkley
Treehouse Guest Teacher

You could return false; at the end of the click handler. This should stop the normal browsing behavior of following the link and opening it in a new window.

You are the man! it works :) Thanks