Jquery - Reading from a Div

We are building a chat engine and when the user clicks on the chat link a popup appears that has a list of the user's latest chats.  This list is being returned through a webservice call inside a string builder that contains all the html.  See attached screen grab (chathtml).

I am tryng to read the data-roomid attribute for whatever chat the user clicks on.  (see attached screen grab chatusers)

I am only able to read the first data-roomid.    Here is the relevant jQuery

$.ajax({
      type: "POST",
        url: "/CMSPages/WebService.asmx/GetMyLatestChats",
        data: {},
       success: function (data) {
          var encodedHtml = data.children[0].innerHTML;
          var decodedHtml = decode(encodedHtml);
          alert(decodedHtml);
          var windowRoomId = $('.chatListWrapper').data('roomid');
       
          $("#frame").addClass("active");
       
        $("#frame").attr("src", "http://172.16.16.31/CMSModules/Chat/CMSPages/ChatRoomWindow.aspx?windowroomid=" + windowRoomId + "&popupSettingsId=" + popupSettingsId);

Does anyone know of anyway I can get the roomid of the chat the user clicked on
chathtml.jpg
chatusers.jpg
sherbug1015Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Alexandre SimõesManager / Technology SpecialistCommented:
You can do a global delegate to all the chat room elements that when clicked you do something.
$(document).on('click', '.chatListWrapper', function(){
     var $this = $(this), 
         roomId = $this.attr('data-roomid');

            // rest of the code

});

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
sherbug1015Author Commented:
Thanks.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
jQuery

From novice to tech pro — start learning today.