Sorting.js - problem with loading images

Sorting.js - problem with loading images

Hello friend,
i really will appreciate your help about a problem that i have with sorting.js

the code is:

  1. /* SORTING */
  2. if (jQuery('.show_album_content').size() > 0) {
  3. var $container = jQuery('.portfolio_grid_isotope');
  4. } else if (jQuery('.portfolio_packery').size() > 0) {
  5. var $container = jQuery('.portfolio_packery');
  6. }

  7. jQuery(function () {
  8. if (jQuery('.show_album_content').size() > 0) {
  9. $container.isotope({
  10. itemSelector: '.element'
  11. });
  12. } else if (jQuery('.portfolio_packery').size() > 0) {
  13. $container.isotope({
  14. itemSelector: '.packery_item',
  15. percentPosition: true,
  16. masonry: {
  17. columnWidth: 1
  18. }
  19. });
  20. }

  21. if (jQuery('.show_album_content').size() > 0 || jQuery('.portfolio_packery').size() > 0) {
  22. var $optionSets = jQuery('.optionset'),
  23. $optionLinks = $optionSets.find('a'),
  24. $showAll = jQuery('.show_all');
  25. $optionLinks.on('click', function () {
  26. var $this = jQuery(this);
  27. // don't proceed if already selected
  28. if ($this.parent('li').hasClass('selected')) {
  29. return false;
  30. }
  31. var $optionSet = $this.parents('.optionset');
  32. $optionSet.find('.selected').removeClass('selected');
  33. $this.parent('li').addClass('selected');
  34. if ($this.attr('data-option-value') == "*") {
  35. $container.removeClass('now_filtering');
  36. } else {
  37. $container.addClass('now_filtering');
  38. }
  39. // make option object dynamically, i.e. { filter: '.my-filter-class' }
  40. var options = {},
  41. key = $optionSet.attr('data-option-key'),
  42. value = $this.attr('data-option-value');
  43. // parse 'false' as false boolean
  44. value = value === 'false' ? false : value;
  45. options[key] = value;
  46. if (key === 'layoutMode' && typeof changeLayoutMode === 'function') {
  47. // changes in layout modes need extra logic
  48. changeLayoutMode($this, options)
  49. } else {
  50. // otherwise, apply new options
  51. $container.isotope(options);
  52. }
  53. return false;
  54. });
  55. }
  56. });

  57. jQuery(window).load(function () {
  58.     if (jQuery('.show_album_content').size() > 0) {
  59.         jQuery('.portfolio_grid_isotope').isotope('reLayout');
  60.     } else if (jQuery('.portfolio_packery').size() > 0) {
  61. $container.isotope('reLayout');
  62. setTimeout("$container.isotope('reLayout')", 500);
  63. setTimeout("$container.isotope('reLayout')", 1000);
  64. }
  65. });
  66. jQuery(window).resize(function () {
  67. if (jQuery('.show_album_content').size() > 0) {
  68. jQuery('.portfolio_grid_isotope').isotope('reLayout');
  69.     } else if (jQuery('.portfolio_packery').size() > 0) {
  70. $container.isotope('reLayout');
  71. setTimeout("$container.isotope('reLayout')", 1000);
  72. }
  73. });
  74.  

when i click on the page of gallery with this sorting script i have this result:



as you can see doesn't load well the images, just a row. The pics are correctly loaded If a refresh the page.
Someone could help me?