Comments (3)
@madcoda9000 This could be done with manipulating DOM element in Javascript. There are many ways to achieve it. here is one way - https://codepen.io/yong-asial/pen/GRXYYvX
HTML
<ons-page id="expanding">
<ons-list>
<ons-list-item expandable id="list1">
<label id="label1">Tap to expand 1</label>
<div class="expandable-content" id="content1">Expandable content 1</div>
</ons-list-item>
<ons-list-item expandable id="list2">
<label id="label2">Tap to expand 2</label>
<div class="expandable-content" id="content2">Expandable content 2</div>
</ons-list-item>
<ons-list-item expandable id="list3">
<label id="label3">Tap to expand 3</label>
<div class="expandable-content" id="content3">Expandable content 3</div>
</ons-list-item>
</ons-list>
</ons-page>
JS
// label - to trigger click event
const label1 = document.getElementById('label1');
const label2 = document.getElementById('label2');
const label3 = document.getElementById('label3');
// list - to listen for click event
const list1 = document.getElementById('list1');
const list2 = document.getElementById('list2');
const list3 = document.getElementById('list3');
const isVisible = (element) => {
return (window.getComputedStyle(element).display !== 'none' && window.getComputedStyle(element).visibility !== 'hidden');
};
const collapseOther = (id) => {
[1, 2, 3].forEach(item => {
if (id !== item) {
const content = document.getElementById('content' + item);
if (isVisible(content)) {
const label = document.getElementById('label' + item);
label.click();
}
}
});
};
const handleListClicked = (event) => {
const labelElement = event.target.children[0] || event.target;
if (labelElement == label1) {
collapseOther(1);
} else if (labelElement == label2) {
collapseOther(2);
} else if (labelElement == label3) {
collapseOther(3);
}
};
[list1, list2, list3].forEach((li) => li.addEventListener('click', handleListClicked));
from onsenui.
This issue is stale because it has been open for 60 days with no activity. If there is no activity in the next 7 days, the issue will be closed.
from onsenui.
This issue was closed because it has been inactive for 7 days since being marked as stale. Please open a new issue if you believe you are encountering a related problem.
from onsenui.
Related Issues (20)
- In-docs Voice/Text Chat 🤩
- Vue3 | Page issue: HOT 3
- Core | issue: ons-input type="file" multiple does not work on macOS HOT 2
- Ons-splitter-mask Not Being Registered HOT 3
- Vue Onsen UI | Peer dependency for Vue 2 is still ~2.6.0 HOT 2
- Can OnsenUI2 run angular.js and Vue3 side by side? HOT 2
- swiperjs and React: Uncaught (in promise) TypeError: Cannot read properties of null (reading 'classList') HOT 5
- 500 Origin Error HOT 2
- Vue | Popover issue: JavaScript Error When Clicking Popover Component Consecutively in onsenUI Versions 2.12.x and Above HOT 3
- Angular1 | Splitter issue: Memory Leak HOT 2
- Error installing vue-onsenui via npm HOT 3
- ons-popover non-functional in Chrome since April 23, 2023 HOT 2
- ionic icons don't work HOT 2
- Angular Ivy Error HOT 2
- v-ons-speed-dial-item component that traverses multiple ICONS and is not fully displayed in the browser HOT 2
- Sponsoring OnsenUI? HOT 3
- Ty HOT 2
- Wrong page element returned, when inserting several pages HOT 1
- does not support angular v17
- ONSEN UI via cdn issue ? my ui in web its break today ?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from onsenui.