Skip to content

Commit 60ec3cb

Browse files
committed
Continue to improve query examples
1 parent 835c0f8 commit 60ec3cb

File tree

7 files changed

+43
-38
lines changed

7 files changed

+43
-38
lines changed

RELEASE-NOTES.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@ Please note after `1.0` Semver will be followed using normal protocols.
3434
* **Feature** - Added `contains()` method for checking if elements contain a specific selector with Shadow DOM support
3535
* **Enhancement** - Enhanced `closest()` with `returnAll` option to optionally return all matching ancestors
3636
* **Improvement** - `offsetParent` has been renamed to `containingParent` and now includes many other possible containing parent checks like `will-change` and `filter`.
37-
* **Bug** - `dataContext()` now returns the entire data context including state
37+
* **Improvement** - `trigger()` now triggers native event handler. Use `dispatchEvent` to avoid this behavior.
38+
* **Improvement** - `.submit()` now uses `requestSubmit` so that it can trigger native event handlers and be cancelable.
39+
* **Bug** - `dataContext()` now returns the entire data context including state.
3840
* **Bug** - `setting()` can now be used as a getter.
3941
* **Bug** - Fixed `offsetParent` to correctly return offset parent for willChange
4042
* **Bug** - Fixed bug where `useAlias()` was not working as intended to alias Query.

docs/src/examples/query/events/query-submit/page.css

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,3 @@
55
margin: var(--vertically-spaced);
66
}
77

8-
.form input {
9-
padding: var(--compact-spacing);
10-
border: var(--border);
11-
border-radius: var(--border-radius);
12-
font-size: inherit;
13-
margin-bottom: var(--compact-spacing);
14-
width: 100%;
15-
}
16-
17-
.status {
18-
padding: var(--compact-spacing);
19-
background: var(--standard-5);
20-
border-radius: var(--border-radius);
21-
22-
&.success {
23-
background-color: var(--success-5);
24-
color: var(--success-80);
25-
}
26-
}
Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<form class="form">
2-
<input type="text" value="Auto-submit in 2s" readonly />
3-
<div class="status">Waiting...</div>
4-
</form>
2+
<ui-input name="name" label="Name" placeholder="Name"></ui-input>
3+
</form>
4+
5+
<ui-button class="submit">Submit</ui-button>
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { $ } from '@semantic-ui/query';
22

3-
$('.form').on('submit', function(e) {
4-
e.preventDefault();
3+
$('form').on('submit', function(event) {
4+
event.preventDefault();
55
$('.status').text('Form submitted!').addClass('success');
66
});
77

8-
setTimeout(() => {
9-
$('.form').submit();
10-
}, 2000);
8+
$('ui-button.submit').on('click', () => {
9+
$('form').submit();
10+
});
Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1-
<input type="text" class="target" placeholder="Will receive focus">
1+
<ui-input type="text" class="target" placeholder="Will receive focus"></ui-input>
22

3-
<ui-button class="trigger" primary>Trigger Focus</ui-button>
3+
<ui-button class="trigger" primary>Trigger Focus</ui-button>
4+
<ui-button class="trigger-mouseenter" secondary>Trigger Mouseenter</ui-button>
5+
6+
7+
<div class="log"></div>
Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
import { $ } from '@semantic-ui/query';
22

3+
// log on mousenter of input
4+
$('.target').on('mouseenter', function() {
5+
$('.log').append('<p>mouse entered input</p>');
6+
});
7+
8+
// trigger focus event including native behavior
39
$('.trigger').on('click', () => {
410
$('.target').trigger('focus');
5-
});
11+
});
12+
13+
// trigger mouseenter event manually
14+
$('.trigger-mouseenter').on('click', () => {
15+
$('.target').trigger('mouseenter');
16+
});

docs/src/examples/query/iterators/query-each/page.js

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,29 @@ $('.iterate').on('click', () => {
88
let results = [];
99
$('.item').each((el, index) => {
1010
$(el).addClass('processed');
11-
results.push(`Item ${index}: "${el.text()}"`);
11+
const text = $(el).text();
12+
results.push(`Item ${index}: "${text}"`);
1213
});
14+
1315
updateOutput(results.join('\n'));
1416
});
1517

1618
$('.number').on('click', () => {
1719
$('.item').each((el, index) => {
18-
$(el).text(`${index + 1}. ${el.text().replace(/^\d+\.\s*/, '')}`);
20+
const text = $(el).text().replace(/^\d+\.\s*/, '');
21+
$(el).text(`${index + 1}. ${text}`);
1922
});
23+
2024
updateOutput('Added numbers to all items');
2125
});
2226

2327
$('.reset').on('click', () => {
24-
$('.item').removeClass('processed');
25-
$('.item').each((el, index) => {
26-
const letters = ['A', 'B', 'C', 'D'];
27-
$(el).text(`Item ${letters[index]}`);
28-
});
28+
$('.item')
29+
.removeClass('processed')
30+
.each((el, index) => {
31+
const letters = ['A', 'B', 'C', 'D'];
32+
$(el).text(`Item ${letters[index]}`);
33+
});
34+
2935
updateOutput('Reset all items');
3036
});

0 commit comments

Comments
 (0)