Created
October 20, 2015 22:36
-
-
Save glinesbdev/9fef599031174a11f33e to your computer and use it in GitHub Desktop.
AJAX MADNESS!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function getSummitMagazineYears() { | |
| var years = []; | |
| $.ajax({ | |
| url: "/corp/News/GetPublicationYears", | |
| data: { TypeId: 1 }, // TypeId 1 = Summit | |
| dataType: "json", | |
| type: "POST", | |
| success: function (data) { | |
| $.each(data, function (index, key) { | |
| years.push(key); | |
| $("<li/>").appendTo($(".summit-wrapper ul.accordion")); | |
| $("<a/>", { id: key, class: "js-accordion-trigger" }).attr("href", "javascript:void(0)").text(key).appendTo($(".summit-wrapper ul.accordion li").last()); | |
| $("<i/>", { class: "fa fa-chevron-right" }).appendTo($(".js-accordion-trigger").last()); | |
| $("<div/>", { class: "submenu" }).insertAfter($(".summit-wrapper ul.accordion li a").last()); | |
| $("<div/>", { class: "grid" }).attr("data-columns", "").appendTo($("div.submenu").last()); | |
| }); | |
| } | |
| }).done(function () { | |
| for (var i = 0; i < years.length; i++) { | |
| $.ajax({ | |
| url: "/corp/News/GetPublications", | |
| data: { TypeId: 1, Year: years[i] }, | |
| dataType: "json", | |
| type: "POST", | |
| success: function (data) { | |
| $(".js-accordion-trigger").each(function () { | |
| var $this = $(this); | |
| $.each(data, function (index, key) { | |
| console.log(key); | |
| if (key.Year === parseInt($this.attr("id"))) { | |
| $("<a/>").attr("href", "/corp/News/Details/" + key.LinkUrlResourceId).appendTo($this.next().find($(".grid"))); | |
| $("<img/>").attr("src", key.ImageUrlResourceId).appendTo($this.next().find($(".grid > a"))); | |
| $("<h6/>").text(key.TitleResourceId).appendTo($this.next().find($(".grid > a"))); | |
| } | |
| }); | |
| }); | |
| } | |
| }); | |
| } | |
| }); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment