WqR128, а в jq есть методы "delete" и "exit"?)
|
Nexus , () по вашему мнению лучше ?)
|
WqR128, что вы вообще пытаетесь сделать используя метод "filter"?
|
Nexus , ок если красивее то пусть будет "each"
|
WqR128, :-?
Я вроде бы не говорил, что что-то в коде у вас "некрасиво", а спросил что вы пытаетесь сделать... |
Фильтр просто так.... Лично меня коробит, что надо делать 2 прогона массива
|
Цитата:
Может лучше так сделать? $.getJSON("https://spreadsheets.google.com/feeds/list/" + spreadsheetID + "/od6/public/values?alt=json", function(data) { var html=[]; $(data.feed.entry).each(function() { if (this.gsx$slag.$t === location.pathname) html.push( '<article class="' + this.gsx$type.$t + '"><header>' +'<h2>' + this.gsx$title.$t + '</h2>' +'</header><img src="' + this.gsx$image.$t + '"/></article>' ); }); $('section').prepend(html.reverse().join('')); }); |
М.Б. как-то в таком стиле? (строки 13-24)
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script> <section></section> <script> var test = { gsx$type:{$t:'testclass'}, gsx$title:{$t:'Test Title'}, gsx$image:{$t:'http://javascript.ru/cat/list/donkey.gif'} }; $('section').html('test content'); var art = $('<article/>', { class: test.gsx$type.$t, html: $('<header/>', { html: $('<h2/>', { text: test.gsx$title.$t }) }) , }); art.append( $('<img/>', { src: test.gsx$image.$t })) art.prependTo($('section')); </script> |
Цитата:
|
Часовой пояс GMT +3, время: 12:29. |