Home How to dynamically show data inside a dynamically added div
Reply: 1

How to dynamically show data inside a dynamically added div

Yash
1#
Yash Published in 2015-11-18 05:23:34Z

I am dynamically adding a div inside another div and I am successful in doing it. However, I want to display data inside the dynamically added div in which I am really stuck. Below is the code:

.js

function GetInfoOnSameActivity(currentElem, priorityObj) {    
        if (priorityObj.UpcomingActivities() != undefined) {
            $.each(priorityObj.UpcomingActivities(), function (i, v) {
            var activityElements = $(currentElem).find('.priority-icon')[i];
            var div = $('<div>').addClass('detail-popup');                
            $(activityElements).append(div);           
                });
    }
  }

This above jquery function is called at the load time. The cshtml is as below:

.cshtml

<div class="priority-icon">                    
                @*<div class="detail-popup">
                    <strong data-bind="text:Title()"></strong>
                    <p data-bind="text:Description()">
                    </p>
                </div>*@
            </div>

The code that I have commented in the .cshtml, is the class that I am adding dynamically. I now want to add the tag values dynamically inside the class detail-popup. Do I need to add and append each tag that I have used in the .cshtml inside the dynamically added div to show their value(eg. <strong>, <p>)

madalinivascu
2#
madalinivascu Reply to 2015-11-18 06:02:57Z

You can append multiple tags like

$('.el').append('<div><p><strong></strong></p></div>');

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.298433 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO