Total Complexity | 2 |
Complexity/F | 1 |
Lines of Code | 21 |
Function Count | 2 |
Duplicated Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | /* globals acf */ |
||
2 | import $ from 'jquery' |
||
3 | |||
4 | acf.addAction('select2_init', function ($select, args, settings, field) { |
||
5 | const $fieldEl = field.$el |
||
6 | |||
7 | $select.on('change', { $fieldEl: $fieldEl }, function () { |
||
8 | const postId = $(this).val() |
||
9 | const postTitle = $(this).find('option:selected').text() |
||
10 | const $postLink = $fieldEl.find('.reusable-postLink') |
||
11 | const oldPostId = $postLink.attr('data-postId') |
||
12 | const $hiddenEl = $fieldEl.find('[hidden]') |
||
13 | const href = $postLink.attr('href') |
||
14 | |||
15 | $hiddenEl.removeAttr('hidden') |
||
16 | $postLink.text(postTitle) |
||
17 | $postLink.attr('data-postId', postId) |
||
18 | $postLink.attr('href', href.replace(oldPostId, postId)) |
||
19 | console.log(href) |
||
|
|||
20 | console.log(postId) |
||
21 | }) |
||
22 | }) |
||
23 |