Форум программистов, компьютерный форум, киберфорум
jQuery
Войти
Регистрация
Восстановить пароль
Блоги Сообщество Поиск Заказать работу  
 
Рейтинг 5.00/3: Рейтинг темы: голосов - 3, средняя оценка - 5.00
30 / 26 / 8
Регистрация: 17.09.2015
Сообщений: 498
Записей в блоге: 6

Помогите построить с помощью JavaScript + jQuery. Хочу взять разметку бред крамбс за основу.

06.12.2018, 18:37. Показов 701. Ответов 2
Метки нет (Все метки)

Студворк — интернет-сервис помощи студентам
Добрый день уважаемые коллеги!

Помогите построить с помощью JavaScript + jQuery


Хочу взять разметку бред крамбс за основу пока.
HTML5
1
2
3
4
5
6
7
<div class="breadcrumb-wrapper col-12">
   <ol class="breadcrumb">
      <li class="breadcrumb-item"><a href="index.html">rubric 1</a></li>
      <li class="breadcrumb-item"><a href="index.html">rubric 2</a></li>
      <li class="breadcrumb-item"><a href="index.html">rubric 3</a></li>
   </ol>
</div>

Желаемое форматирование
HTML5
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<tbody>
 
  <tr data-rubric-id="1">
    <td>
      <ol class="breadcrumb">
        <li class="breadcrumb-item"><a href="index.html">Корневая рубрика</a></li>
      </ol>
    </td>
  </tr>
  <tr data-rubric-id="3">
    <td>
      <ol class="breadcrumb">
        <li class="breadcrumb-item"><a href="index.html">Корневая рубрика</a></li>
        <li class="breadcrumb-item"><a href="index.html">Рубрика которая лежит в корневой рубрике</a></li>
      </ol>
    </td>
  </tr>
  <tr data-rubric-id="4">
    <td>
      <ol class="breadcrumb">
        <li class="breadcrumb-item"><a href="index.html">Корневая рубрика</a></li>
        <li class="breadcrumb-item"><a href="index.html">Рубрика которая лежит в корневой рубрике</a></li>
        <li class="breadcrumb-item"><a href="index.html">Суб рубрика
              </a></li>
      </ol>
    </td>
  </tr>
</tbody>

Имею ответ сервера собственного производства
JSON
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
{
    "error_code": 0,
    "count": 4,
    "items": [
        {
            "post_rubric_id": "1",
            "user_id": "1",
            "parent_id": "0",
            "create_at": "2018-11-29 01:35:16",
            "update_at": "2018-12-05 16:55:40",
            "post_rubric_description_id": "3",
            "language_id": "1",
            "description_title": "Корневая рубрика",
            "description_content": null,
            "meta_tag_title": null,
            "meta_tag_description": null,
            "meta_tag_keyword": null
        },
        {
            "post_rubric_id": "3",
            "user_id": "1",
            "parent_id": "1",
            "create_at": "2018-12-06 14:35:34",
            "update_at": "2018-12-06 14:35:34",
            "post_rubric_description_id": "6",
            "language_id": "1",
            "description_title": "Рубрика которая лежит в корневой рубрике",
            "description_content": null,
            "meta_tag_title": null,
            "meta_tag_description": null,
            "meta_tag_keyword": null
        },
        {
            "post_rubric_id": "4",
            "user_id": "1",
            "parent_id": "3",
            "create_at": "2018-12-06 16:03:19",
            "update_at": "2018-12-06 16:03:19",
            "post_rubric_description_id": "7",
            "language_id": "1",
            "description_title": "Суб рубрика",
            "description_content": null,
            "meta_tag_title": null,
            "meta_tag_description": null,
            "meta_tag_keyword": null
        }
    ]
}
Сейчас у меня это выглядит так


первая картинка решается вот таким кодом
JavaScript
1
2
3
4
5
6
7
8
9
10
11
12
const buildRubric = function (data) {
                let findcat = id => {
                    let p = data.find(v => v.post_rubric_id === id);
                    if (p.parent_id === "0")
                        return  p.description_title;
                    return    `${findcat(p.parent_id)} > ${p.description_title}`;
                };
                return   data.map(v => findcat(v.post_rubric_id));
            };
 
 
            let path = buildRubric(response.items);
Хочу что бы выглядело так
0
cpp_developer
Эксперт
20123 / 5690 / 1417
Регистрация: 09.04.2010
Сообщений: 22,546
Блог
06.12.2018, 18:37
Ответы с готовыми решениями:

Хочу изучить MySQL, PHP, Javascript, Jquery. Мне нужен УЧИТЕЛЬ.
Приветствую всех веб-мастеров на форуме, есть большое желание учится - нет учителя, знаю на начальном уровне html и css, хотелось бы...

Как с помощью jQuery генерировать JavaScript?
Беда вот в чем, есть огромный код, который формирует массив всякого разного добра и в итоге из этого всего формируется html код в виде...

Помогите перевести код jQuery на JavaScript
$('.menu-btn').on('click', function(e) { e.preventDefault(); $('.menu').toggleClass('menu_active'); ...

2
30 / 26 / 8
Регистрация: 17.09.2015
Сообщений: 498
Записей в блоге: 6
06.12.2018, 23:26  [ТС]
Я думаю решение найдено!

В php немного подшаманил, что бы он мне возвращал рубрики и их родителей
Так как в JS не селен.


JSON
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
{
    "error_code": 0,
    "count": 5,
    "items": [
        {
            "post_rubric_id": "1",
            "user_id": "1",
            "parent_id": "0",
            "create_at": "2018-11-29 01:35:16",
            "update_at": "2018-12-05 16:55:40",
            "post_rubric_description_id": "3",
            "language_id": "1",
            "description_title": "Корневая рубрика",
            "description_content": null,
            "meta_tag_title": null,
            "meta_tag_description": null,
            "meta_tag_keyword": null,
            "parent": []
        },
        {
            "post_rubric_id": "2",
            "user_id": "1",
            "parent_id": "3",
            "create_at": "2018-12-05 16:56:17",
            "update_at": "2018-12-06 22:00:56",
            "post_rubric_description_id": "8",
            "language_id": "1",
            "description_title": "Какая то рубрика",
            "description_content": null,
            "meta_tag_title": null,
            "meta_tag_description": null,
            "meta_tag_keyword": null,
            "parent": [
                {
                    "post_rubric_id": "1",
                    "user_id": "1",
                    "parent_id": "0",
                    "create_at": "2018-11-29 01:35:16",
                    "update_at": "2018-12-05 16:55:40",
                    "post_rubric_description_id": "3",
                    "language_id": "1",
                    "description_title": "Корневая рубрика",
                    "description_content": null,
                    "meta_tag_title": null,
                    "meta_tag_description": null,
                    "meta_tag_keyword": null
                },
                {
                    "post_rubric_id": "3",
                    "user_id": "1",
                    "parent_id": "1",
                    "create_at": "2018-12-06 14:35:34",
                    "update_at": "2018-12-06 14:35:34",
                    "post_rubric_description_id": "6",
                    "language_id": "1",
                    "description_title": "Рубрика которая лежит в корневой рубрике",
                    "description_content": null,
                    "meta_tag_title": null,
                    "meta_tag_description": null,
                    "meta_tag_keyword": null
                }
            ]
        },
        {
            "post_rubric_id": "3",
            "user_id": "1",
            "parent_id": "1",
            "create_at": "2018-12-06 14:35:34",
            "update_at": "2018-12-06 14:35:34",
            "post_rubric_description_id": "6",
            "language_id": "1",
            "description_title": "Рубрика которая лежит в корневой рубрике",
            "description_content": null,
            "meta_tag_title": null,
            "meta_tag_description": null,
            "meta_tag_keyword": null,
            "parent": [
                {
                    "post_rubric_id": "1",
                    "user_id": "1",
                    "parent_id": "0",
                    "create_at": "2018-11-29 01:35:16",
                    "update_at": "2018-12-05 16:55:40",
                    "post_rubric_description_id": "3",
                    "language_id": "1",
                    "description_title": "Корневая рубрика",
                    "description_content": null,
                    "meta_tag_title": null,
                    "meta_tag_description": null,
                    "meta_tag_keyword": null
                }
            ]
        },
        {
            "post_rubric_id": "4",
            "user_id": "1",
            "parent_id": "3",
            "create_at": "2018-12-06 16:03:19",
            "update_at": "2018-12-06 16:03:19",
            "post_rubric_description_id": "7",
            "language_id": "1",
            "description_title": "Суб рубрика",
            "description_content": null,
            "meta_tag_title": null,
            "meta_tag_description": null,
            "meta_tag_keyword": null,
            "parent": [
                {
                    "post_rubric_id": "1",
                    "user_id": "1",
                    "parent_id": "0",
                    "create_at": "2018-11-29 01:35:16",
                    "update_at": "2018-12-05 16:55:40",
                    "post_rubric_description_id": "3",
                    "language_id": "1",
                    "description_title": "Корневая рубрика",
                    "description_content": null,
                    "meta_tag_title": null,
                    "meta_tag_description": null,
                    "meta_tag_keyword": null
                },
                {
                    "post_rubric_id": "3",
                    "user_id": "1",
                    "parent_id": "1",
                    "create_at": "2018-12-06 14:35:34",
                    "update_at": "2018-12-06 14:35:34",
                    "post_rubric_description_id": "6",
                    "language_id": "1",
                    "description_title": "Рубрика которая лежит в корневой рубрике",
                    "description_content": null,
                    "meta_tag_title": null,
                    "meta_tag_description": null,
                    "meta_tag_keyword": null
                }
            ]
        },
        {
            "post_rubric_id": "5",
            "user_id": "1",
            "parent_id": "4",
            "create_at": "2018-12-06 20:24:31",
            "update_at": "2018-12-06 20:27:21",
            "post_rubric_description_id": "9",
            "language_id": "1",
            "description_title": "3 level",
            "description_content": null,
            "meta_tag_title": null,
            "meta_tag_description": null,
            "meta_tag_keyword": null,
            "parent": [
                {
                    "post_rubric_id": "1",
                    "user_id": "1",
                    "parent_id": "0",
                    "create_at": "2018-11-29 01:35:16",
                    "update_at": "2018-12-05 16:55:40",
                    "post_rubric_description_id": "3",
                    "language_id": "1",
                    "description_title": "Корневая рубрика",
                    "description_content": null,
                    "meta_tag_title": null,
                    "meta_tag_description": null,
                    "meta_tag_keyword": null
                },
                {
                    "post_rubric_id": "3",
                    "user_id": "1",
                    "parent_id": "1",
                    "create_at": "2018-12-06 14:35:34",
                    "update_at": "2018-12-06 14:35:34",
                    "post_rubric_description_id": "6",
                    "language_id": "1",
                    "description_title": "Рубрика которая лежит в корневой рубрике",
                    "description_content": null,
                    "meta_tag_title": null,
                    "meta_tag_description": null,
                    "meta_tag_keyword": null
                },
                {
                    "post_rubric_id": "4",
                    "user_id": "1",
                    "parent_id": "3",
                    "create_at": "2018-12-06 16:03:19",
                    "update_at": "2018-12-06 16:03:19",
                    "post_rubric_description_id": "7",
                    "language_id": "1",
                    "description_title": "Суб рубрика",
                    "description_content": null,
                    "meta_tag_title": null,
                    "meta_tag_description": null,
                    "meta_tag_keyword": null
                }
            ]
        }
    ]
}

Предварительно конечный результат:
JavaScript
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
function fillRubricTable(response) {
        if (response.error_code === 0) {
            
            $('#rubric-table tbody tr').remove();
 
            for (let i = 0; i < response.items.length; i++) {
 
 
                var $path = null;
                $path = $('<ol>').attr('class', 'breadcrumb');
                
                for (let j = 0; j < response.items[i].parent.length; j++) {
                    $path.append($('<li>')
                        .attr('class', 'breadcrumb-item')
                        .append($('<a>')
                            .text(response.items[i].parent[j].description_title)
                        )
                    );
                }
 
 
                $('#rubric-table tbody')
                    .append($('<tr>')
                        .attr('data-rubric-id', response.items[i].post_rubric_id)
                        .append($('<td>')
                            .append($('<div class="media-body w-100">')
                                .append($('<p class="list-group-item-text text-truncate text-bold-600 mb-0">').text(response.items[i].description_title))
                                .append($path)
                            )
                        )
                    )
            }
        }
    }


Графическое представление:
0
30 / 26 / 8
Регистрация: 17.09.2015
Сообщений: 498
Записей в блоге: 6
06.12.2018, 23:31  [ТС]
0
Надоела реклама? Зарегистрируйтесь и она исчезнет полностью.
raxper
Эксперт
30234 / 6612 / 1498
Регистрация: 28.12.2010
Сообщений: 21,154
Блог
06.12.2018, 23:31
Помогаю со студенческими работами здесь

С помощью библиотеки jQuery, или просто на JavaScript, сделайте Sprite анимацию
помощью библиотеки JQuery, или просто на JavaScript, сделайте Sprite анимацию.

С помощью jQuery Ajax подгружать файлы (javascript) при изменении передаваемых данных
Необходимо с помощью jQuery Ajax подгружать файлы (javascript) при изменении передаваемых данных. Как это реализовать?

подскажите какую CMS взять за основу
интересно что взять за основу чтобы сделать подобное _www.pulscen.ru

не знаю какую схему отладочной взять за основу
В общем помаленьку начал читать книжку, по программированию МК AVR. Назрел вопрос, а ведь надо же програмки на чем то отрабатывать. ...

Первые шаги в JQuery (хочу добавить переменную в код JQuery)
Здравствуйте. Захотел сделать галерею на сайте и чтобы при нажатии на кнопу показывало случайную картинку, но не понимаю как вставить...


Искать еще темы с ответами

Или воспользуйтесь поиском по форуму:
3
Ответ Создать тему
Новые блоги и статьи
Access
VikBal 11.12.2025
Помогите пожалуйста !! Как объединить 2 одинаковые БД Access с разными данными.
Новый ноутбук
volvo 07.12.2025
Всем привет. По скидке в "черную пятницу" взял себе новый ноутбук Lenovo ThinkBook 16 G7 на Амазоне: Ryzen 5 7533HS 64 Gb DDR5 1Tb NVMe 16" Full HD Display Win11 Pro
Музыка, написанная Искусственным Интеллектом
volvo 04.12.2025
Всем привет. Некоторое время назад меня заинтересовало, что уже умеет ИИ в плане написания музыки для песен, и, собственно, исполнения этих самых песен. Стихов у нас много, уже вышли 4 книги, еще 3. . .
От async/await к виртуальным потокам в Python
IndentationError 23.11.2025
Армин Ронахер поставил под сомнение async/ await. Создатель Flask заявляет: цветные функции - провал, виртуальные потоки - решение. Не threading-динозавры, а новое поколение лёгких потоков. Откат?. . .
Поиск "дружественных имён" СОМ портов
Argus19 22.11.2025
Поиск "дружественных имён" СОМ портов На странице: https:/ / norseev. ru/ 2018/ 01/ 04/ comportlist_windows/ нашёл схожую тему. Там приведён код на С++, который показывает только имена СОМ портов, типа,. . .
Сколько Государство потратило денег на меня, обеспечивая инсулином.
Programma_Boinc 20.11.2025
Сколько Государство потратило денег на меня, обеспечивая инсулином. Вот решила сделать интересный приблизительный подсчет, сколько государство потратило на меня денег на покупку инсулинов. . . .
Ломающие изменения в C#.NStar Alpha
Etyuhibosecyu 20.11.2025
Уже можно не только тестировать, но и пользоваться C#. NStar - писать оконные приложения, содержащие надписи, кнопки, текстовые поля и даже изображения, например, моя игра "Три в ряд" написана на этом. . .
Мысли в слух
kumehtar 18.11.2025
Кстати, совсем недавно имел разговор на тему медитаций с людьми. И обнаружил, что они вообще не понимают что такое медитация и зачем она нужна. Самые базовые вещи. Для них это - когда просто люди. . .
Создание Single Page Application на фреймах
krapotkin 16.11.2025
Статья исключительно для начинающих. Подходы оригинальностью не блещут. В век Веб все очень привыкли к дизайну Single-Page-Application . Быстренько разберем подход "на фреймах". Мы делаем одну. . .
Фото: Daniel Greenwood
kumehtar 13.11.2025
КиберФорум - форум программистов, компьютерный форум, программирование
Powered by vBulletin
Copyright ©2000 - 2025, CyberForum.ru