Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1090133
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T23:19:34+00:00 2026-05-16T23:19:34+00:00

hi, i am not sharing code. the problem is in this code please take

  • 0

hi, i am not sharing code. the problem is in this code please take a look. (problem: I want to open facebox every time when post even come from ajax facebox is not working properly. I want to ask how to use jQuery delegation event with this event? )

<!DOCTYPE html>
<html lang="en">
<head>
    <link rel="stylesheet" href="facebox/facebox.css" type="text/css" />    
</head>
<body>

<ul id="items">
    <li> <a href='#'> Clone Object </a> </li>
    <li> <a href='#test' rel='facebox'> Click to open facebox </a> </li>
</ul>

<div id="test" style="display:none;">this is my test div</div>

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
<script type="text/javascript" src="facebox/facebox.js"></script>

<script type="text/javascript">

    jQuery('a[rel*=facebox]').facebox();

    $("#items li").delegate('a', 'click', function(){
        $(this).parent().append('<li><a href="#test" rel="facebox"> New Element ( problem: it should open facebox) </a></li>');
        return false;
    });

</script> 

</bdoy>
</html>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T23:19:35+00:00Added an answer on May 16, 2026 at 11:19 pm

    A few things, first change to using .live(), by switching this:

    jQuery('a[rel*=facebox]').facebox();
    

    For this:

    jQuery('a[rel*=facebox]').live('click', function(e) {
      $.facebox({ div: this.hash });
      e.preventDefault();
    });
    

    Or the .delegate() version:

    $('#items').delegate('a[rel*=facebox]', 'click', function(e) {
      $.facebox({ div: this.hash });
      e.preventDefault();
    });
    

    Then your .parent() call is appending an <li> to an <li>, instead you should replace:

    $(this).parent()
    

    With .cloest() so it goes up to the <ul> and appends it as a child there, like this:

    $(this).closest("ul")
    

    You can test out the updated version with the above changes (without images) here.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Update : Unfortunately the help offered below did not solve my problem of sharing
http://code.flickr.com/blog/page/4/ This blog post is from the devs at Flickr, and outlines their simplified
Somebody please help me out. This problem is killing me. I went through tones
Have a look at this F#/OCaml code: type AllPossible = | A of int
This code opens a directory, and for every file in the directory it loops
Historical Context: This problem ended up being not at all what I thought it
At work, development uses perforce to handle code sharing. I won't say revision control,
I have, essentially, the same problem as this poster, but in C#: Waiting until
Perl threads do not support sharing filehandles. All the elements of a shared data
I have a computational algebra task I need to code up. The problem is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.