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 9181583
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T18:21:03+00:00 2026-06-17T18:21:03+00:00

I have some rows in my database including name, description and an image. What

  • 0

I have some rows in my database including name, description and an image.

What I’m looking to do though, is to display these records in a HTML list, that has a ‘link/button’ that when I click on it, it opens a jQuery dialog with the image inside it.

What I’m doing so far, is looping through the records passing the object to a partial. The partial includes a div that simply displays the image.

I have so far:

editSuccess.php

 $( ".image" ).dialog({
    autoOpen: false,
    height: 1000,
    width: 1000,
    position: [130, -100],
    modal: true,
    buttons: {
    Close: function() {
        $( this ).dialog( "close" );
    }
    },
    close: function() {
    }
 });

 $(".view-image" )
        .button()
        .click(function() {
            $( ".image" ).dialog( "open" );
});

<?php foreach($items as $item): ?>
    <div class="item">
        <?php echo $item->getName(); ?>
        <?php include_partial('templates/editTemplate', array('item'=>$item)); ?>
        <button class="view-image">View</button>
    </div>
<?php endforeach; ?>

_editTemplate.php

<div class="image">
    <?php echo $item->getImage(); ?>
</div>

The problem is, there is 10 records that are output. When I click on the ‘View’ button, it opens up a dialog for each one of the 10 items.

Is there a way were I click on a ‘View’ it only opens the dialog for that actual record?

  • 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-06-17T18:21:05+00:00Added an answer on June 17, 2026 at 6:21 pm

    Your code pretty much calls the modal to open up every class that has image. You have to specify the context on which specific image you want to open instead.

    <script>
    $(function() {
    
        /** Modal dialog */
        var dialog = function (content) {
            var modal;
            if (!$('#modal').length) {
                $('body').append($('<div id="modal"></div>'));
                $(document.body).append(modal);         
            }
            modal = $('#modal');
            modal.dialog({
                autoOpen: true,
                height: 1000,
                width: 1000,
                position: [130, -100],
                modal: true,
                buttons: {
                    Close: function () {
                        $(this).dialog("close");
                    }
                },
                close: function () {}
            });
            modal.html(content);
       };
    
       $('.view-image').click(function(e) {
          // Call the dialog and pass the content of the image class.
          dialog($(".image", $(this).parent('.item')).html());
    
          return false;   
       });
    
    });
    </script>
    
    ...Your PHP code follows.
    

    To resolve your jQuery UI dialog specific issue, here’s the jsFiddle address the dialog issue (concept-wise). jsFiddle

    I updated the answer above on how this can be integrated with your PHP app.

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

Sidebar

Related Questions

so in my database some rows have NULL values, and when I select *
I have a database table with some rows that I want to fetch using
I have 2 tables, where I have some rows with some image buttons. What
I have some rows in my database that contains some dates. I need to
I have a some exported rows that I want to import into a database
I have to delete some rows in the database. I'm using Entity Framework 4.3
I have some rows in a MySQL database which are duplicates, except for their
I have to select some rows from the database using IN operator. I want
I have some rows ( > 50.000) in my database which contains columns with
I have an Android SQLite Database and I inserted some rows. After I deleted

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.