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

  • SEARCH
  • Home
  • 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 6914085
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T09:18:08+00:00 2026-05-27T09:18:08+00:00

Basically, I have a dynamically created list and I have no idea in advance

  • 0

Basically, I have a dynamically created list and I have no idea in advance how many items there will be.

I need each one to launch a slightly different Ajax function on clicking.

I am currently using JQM for the modal boxes (happy to switch if someone knows something better).

The following code works fine for making all .ajaxpopup items launch the same page :

  $().ready(function () {
            $('#dialog').jqm({ ajax: "/QuestionManager/AjaxPopup/1", trigger: ".ajaxpopup" });

            $(".ajaxpopup").click(function (e) {
                e.preventDefault();
            });

However, I need each item to launch a different page (1/2… I don’t know the ID in advance).

I really like Adam’s answer about adding a data-itemid tag to the element, but, I just can’t seem to actually make this work.

I do not know if this is a JQM limitation or due to the way it is initiated.

The closest I have come is:

$(document).on("click", "a", function () {
        var itemId = $(this).data("itemid");

        $('#dialog').jqm({ ajax: "/QuestionManager/AjaxPopup/"+itemId, trigger: ".ajaxpopup" });
    });

I have also replaced the dialog line with alert(itemId), which is giving the correct result, so, I know I am along the right path – I just can’t seem to get this done!

Can anyone help?

  • 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-27T09:18:09+00:00Added an answer on May 27, 2026 at 9:18 am

    You can wire dyanmically added content to respond to events via jQuery’s live and on functions.

    So if I’m understanding your particular case, you want those text nodes, when clicked, to launch a jqm modal? And you want your model’s itemId to be a part of it?

    First, add the itemId to your text via a data attribute:

    @foreach (var item in Model.Routines)
    {
        <text data-itemid='@item.itemId'></text>
    } //(sorry if the razor syntax is off a bit - that's not my expertise
    

    And then:

    $(document).on("click", "text", function() { 
        var itemId = $(this).data("itemid");
        var textnodeText = $(this).text();
        $('#dialog').jqm({ ajax: "/QuestionManager/_AjaxCreateQuestionInitial/" + textnodeText, 
                           trigger: itemId });
    });
    

    EDIT

    Based on your comment, if you have this html:

    <a href="/test/AddData" data-itemid="1">Add Data</a>
    

    You can handle the click event like this:

    $(document).on("click", "a", function() {
        var itemId = $(this).data("itemid");
        //now run your ajax call
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

What I have is a dynamically created list thats built off a each loop.
I have created a 3D structure(basically an image) dynamically using kit3D.However,I wanted to zoom
Basically I have a set of checkboxes that are dynamically created from view data
I have a set of accordion panes(dynamically created) contained in an Accordion control. Basically,
I need some help with defining a dynamic method. Basically, I have many classes
I basically have 7 select statements that I need to have the results output
ok so I am trying to dynamically create a select list using javascript, basically
I have an MVC app that is basically one page with a bunch of
I'm not sure if I created this topic correctly, but basically I have a
So I have a MySQL query that is being created dynamically based on parameters

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.