Google Groups Home
Help | Sign in
Face box doesn't work with INNER HTML any suggestions
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  4 messages - Collapse all
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
raknin  
View profile
 More options May 7, 2:09 am
From: raknin <rak...@gmail.com>
Date: Tue, 6 May 2008 23:09:29 -0700 (PDT)
Local: Wed, May 7 2008 2:09 am
Subject: Face box doesn't work with INNER HTML any suggestions
Hi,

I am using the following code:

---  Code start ----

<html>

<head>

<title></title>

<script language="javascript"  src="js/jquery.js" type="text/
javascript"></script>
<script language="javascript"  src="js/facebox.js" type="text/
javascript"></script>
<link rel="stylesheet" type="text/css" href="facebox.css"
media="screen" />

<script language="javascript" type="text/javascript">
 jQuery(document).ready(function($) {
      $('a[rel*=facebox]').facebox({
        loading_image : 'loading.gif',
        close_image   : 'closelabel.gif'
      })
    })
</script>

<script language="javascript" type="text/javascript">
function test()
{

var image = '<a href="image1.jpg" rel="facebox"><img src="image1.jpg"
width="200" height="200"  align="absmiddle" alt="Click for larger
picture"></a>';
document.getElementById('imageDIV').innerHTML=image;

}

</script>

</head>

<body>

<input name="Test" id="Test" type="button" value="Test"
onclick="test();">

<div id="imageDIV">
</div>
</body>

</html>

---  End of code---

The problem is that I don't see any box when I click on the image. I
am using innerhtml. when I put imag1 statement inside the body it is
working fine, any suggestions?


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Chris Wanstrath  
View profile
 More options May 7, 3:05 pm
From: "Chris Wanstrath" <ch...@ozmm.org>
Date: Wed, 7 May 2008 12:05:33 -0700
Local: Wed, May 7 2008 3:05 pm
Subject: Re: Face box doesn't work with INNER HTML any suggestions
Use the LiveQuery plugin to maintain behaviors across Dom manipulations.

You can't attach behavior to an anchor tag that only exists in a string.

- Chris

On 5/6/08, raknin <rak...@gmail.com> wrote:

--
Chris Wanstrath
http://github.com/defunkt

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
paul.roberts  
View profile
 More options May 8, 3:49 am
From: "paul.roberts" <paul.robe...@riddenpath.co.uk>
Date: Thu, 8 May 2008 00:49:45 -0700 (PDT)
Local: Thurs, May 8 2008 3:49 am
Subject: Re: Face box doesn't work with INNER HTML any suggestions
I am not sure if you have figured this out but I have a solution that
is working for me:

document.getElementById({ELEMENTID}).innerHTML=arrItems[1];
reInitFacebox(arrItems[{ELEMENTID}]);

FUNCTION :

    function reInitFacebox(objPass){
        jQuery(document).ready(function($) {
        $('#' + objPass + ' a[rel*=facebox]').facebox()
        })

If you pass the Element ID through to reInitFacebox({ELEMENTID})  and
this line $('#' + objPass + ' a[rel*=facebox]').facebox() apparently
reinitialise that element.  Get it wrong and that single element will
work but all the other elements will reinitialise every time and will
show multiple times.  Play with it abit.

Let me know how it works.

On May 7, 7:09 am, raknin <rak...@gmail.com> wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jon  
View profile
 More options May 8, 3:02 pm
From: Jon <jnas...@gmail.com>
Date: Thu, 8 May 2008 12:02:45 -0700 (PDT)
Local: Thurs, May 8 2008 3:02 pm
Subject: Re: Face box doesn't work with INNER HTML any suggestions
jQuery(document).ready() is executed before the image exists in the
DOM.

I tested your above code with the test() function defined as:

function test()  {
        var image = '<a href="image.gif" rel="facebox"><img src="image.gif"
width="200"
                height="200"  align="absmiddle" alt="Click for larger picture"></
a>';

        //$("#imageDIV").html(image);
        //$("#imageDIV > a[rel*=facebox]").facebox();

        document.getElementById('imageDIV').innerHTML=image;

}

This displays the image but, as you describe, doesn't use facebox when
you click on it.  The reason is that you have to activate facebox on
that link once you have added it to the DOM.  Since facebox is
designed to work as a jQuery plugin you really can't give the link an
ID and then make a second call to document.getElementById to call
facebox() to initialize it.

Since you have jQuery loaded anyway the easiest way to handle this is
to just use jQuery for everything.  Remove the document.getElementById
line and uncomment the 2 lines above it.

jQuery adds the image string to the imageDIV and then selects just the
anchors in that one DIV to initialize facebox on.

I hope this helps.

-Jon

On May 8, 3:49 am, "paul.roberts" <paul.robe...@riddenpath.co.uk>
wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2008 Google