kipris kipris - 7 months ago 39
Javascript Question

Jquery: show and hide portlets

Trying to show/hide my portlet and nothing happen :(
http://plnkr.co/edit/1rjq3UzJ6NYaDU2mNS2O?p=preview

$("#add").click(function() {
$("#porlet1 portlet-body").hide();
$("#porlet1").hide();
$("#porlet2").show();
setTimeout(function(){
$("#porlet2 portlet-body").show();
}, 100);
});

$("#remove").click(function() {
$("#porlet2 portlet-body").hide();
$("#porlet2").hide();
$("#porlet1").show();
setTimeout(function(){
$("#porlet1 portlet-body").show();
}, 100);
});


In my real project porlet1 hides and portlet2 shows. After 2nd hiding the 1st appears and then I click to show the 2nd and all porlets hide.

Answer

change your js code.. in Your code typo mistakes are there. id's speling are incorrect

$(document).ready(function(){
$("#add").click(function() {

   $("#portlet1 .portlet-body").hide();
  $("#portlet1").hide();
  $("#portlet2").show();
  setTimeout(function(){
    $("#portlet2 .portlet-body").show();
  }, 100);
});

$("#remove").click(function() {
  $("#portlet2 .portlet-body").hide();
  $("#portlet2").hide();
  $("#portlet1").show();
  setTimeout(function(){
    $("#portlet1 .portlet-body").show();
  }, 100);
});
})
Comments