Hello. There is such a problem. I have a news feed of users. News is displayed in a loop ( do-while ). How to make it so that when you click on the " Details " button, the mod will open. a window with full news and comments on this news, as well as a block for adding comments. Those. I want to learn javascript , which will open the mod. windows by unique news id. A unique news id is created automatically in a loop. And what about JS , which will open exactly this little window of this news, I don’t know.
I hope very much for your help.

    1 answer 1

    Like that.

    $("a.full_post").click(function(){ var id = $(this).attr("id"); var elem = $("div#post"); $.ajax({ url: "/myajax.php", dataType: "text", type: "POST", data: {id:id}, success: function(response) { elem.html(response); } }); elem.dialog(); return false; }); 

    Where a.full_post is a view link.

     <a href="#" class="full_post" id="id-статьи">Подробнее</a> 

    $("div#post") - div, which will load the text of the article.

     <div id="post"></div> 

    JS script naturally need to frame $(document).ready(fn);

    • Yes, I use jquery-ui dialog, but how to make this window open this news. As I already wrote, these news are displayed in a cycle and there can be more than a hundred of them on the page. They have a "Read More" button with a unique ID. How to modify the JS output function of modal windows? - Nikolay Nikonov
    • With the "Подробнее..." link "Подробнее..." pass the ID-article parameter to the JS script, which executes the AJAX request to the server, receives the text of the desired article and inserts it into the <div> on which you have the dialog() . - DemoS
    • I'm a teapot in js. Therefore, I do not know how such simple things are done as the adoption of the ID parameter. You can write the entire JS script in detail. I will be very grateful. - Nikolay Nikonov
    • Updated the answer - DemoS
    • one
      @ Nikolai, if it worked out, there is a check mark to the left of the answer. Click it, if not hard). - ling