6 Replies - 354 Views - Last Post: 12 February 2017 - 10:33 AM

#1 daymaker  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 11
  • Joined: 11-February 17

Hide/Show user's popup modal

Posted 11 February 2017 - 08:47 PM

I need to hide/show user specific pop-ups on click of each of the user (user-div).
This works fine when the users are sorted based on their lastname. However, after sorting, it doesn't work as expected.

Please check the code below along with the attachments.

/* Sort function */
allUsers = $(".user-container");
$("#btn-des").on('click',function(){
  var desc = allUsers.sort(function(a,B)/>/>{
	return $(a).find(".user-name").text() > $(B)/>/>.find(".user-name").text(); 
  });
  $(".wrapper").html(desc);				 
});
		 
$("#btn-asc").on('click',function(){
  var asc = allUsers.sort(function(a,B)/>/>{
	return $(a).find(".user-name").text() < $(B)/>/>.find(".user-name").text();					 
  });
  $(".wrapper").html(asc);				 
});

/* User pop-up Hide/Show */
$('.user-modal').hide(); //for hiding all modals on load
$('.close-btn').click(function(){
  $(this).parent().hide();
});
$('.user-container').click(function(){
  $('.user-modal').hide();
  $("#"+$(this).attr("data-mod-id")).show();
});




For complete details (HTML, CSS, jQuery code), please check the attachments.

Attached File(s)

  • Attached File  file.zip (2.82K)
    Number of downloads: 20


Is This A Good Question/Topic? 0
  • +

Replies To: Hide/Show user's popup modal

#2 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 4123
  • View blog
  • Posts: 13,011
  • Joined: 08-June 10

Re: Hide/Show user's popup modal

Posted 12 February 2017 - 02:41 AM

What does 'doesn't work as expected' mean?
Was This Post Helpful? 0
  • +
  • -

#3 daymaker  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 11
  • Joined: 11-February 17

Re: Hide/Show user's popup modal

Posted 12 February 2017 - 02:58 AM

View PostDormilich, on 12 February 2017 - 02:41 AM, said:

What does 'doesn't work as expected' mean?

Once, I sort the users, I cannot open the pop-ups by clicking on a user.
Was This Post Helpful? 0
  • +
  • -

#4 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 4123
  • View blog
  • Posts: 13,011
  • Joined: 08-June 10

Re: Hide/Show user's popup modal

Posted 12 February 2017 - 03:48 AM

that's due to calling .html() since it deletes your event assignments.
Was This Post Helpful? 0
  • +
  • -

#5 daymaker  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 11
  • Joined: 11-February 17

Re: Hide/Show user's popup modal

Posted 12 February 2017 - 06:33 AM

View PostDormilich, on 12 February 2017 - 03:48 AM, said:

that's due to calling .html() since it deletes your event assignments.

Oh...how do I fix that now?
Was This Post Helpful? 0
  • +
  • -

#6 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 4123
  • View blog
  • Posts: 13,011
  • Joined: 08-June 10

Re: Hide/Show user's popup modal

Posted 12 February 2017 - 09:28 AM

most likely by using delegated events
Was This Post Helpful? 0
  • +
  • -

#7 andrewsw  Icon User is online

  • lashings of ginger beer
  • member icon

Reputation: 6333
  • View blog
  • Posts: 25,540
  • Joined: 12-December 12

Re: Hide/Show user's popup modal

Posted 12 February 2017 - 10:33 AM

Understanding Event Delegation
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1