Comments (6)
Are you not keeping state of tabState in the model?
Based on the instructions, I placed tabState in the model and I init as Tab.initialState. You can check the Msg when the user clicks on a tab:
TabMsg State …
▾0 = {
activeTab = Just "tabItem2"
visibility = Showing
}
from elm-bootstrap.
"Are you not keeping state of tabState in the model?"
Yes, I am. But can I access State
record on the case/of? In the Elm Bootstrap package the custom type is private.
from elm-bootstrap.
one workaround might be to use the Browser.navigation module, the chosen tab could be sent as a url hash (nice for deep linking as well). Then you can pick up the active tab and just in time render the view (and fetch needed data, probably with your own custom state handling for pending/success/error states for the remote request(s) etc).
from elm-bootstrap.
Indeed, this is a opaque type (https://github.com/rundis/elm-bootstrap/blob/master/src/Bootstrap/Tab.elm#L84)
So unfortunately I don't know how one can access these values (I'm somewhat new to Elm). From what I can tell this pattern is meant, as you say, to be private in order to not break apps with future changes, which in this instance kind of sucks if you ask me since it seems like it would be a very useful thing and would support the most basic and standard Elm pattern listen to Msg in update -> update model -> (optional) trigger Cmd
.
Of course @rundis knows best (he's the author after all). His workaround should work and it's probably a more generic and robust way to do it, backwards compatible that won't break if any internal changes occur. Thanks for the learning experience, I hope this also helps others.
(This is as far as I got doing the case...of approach)
from elm-bootstrap.
On my side I've solved the issue by copying and edit the original code like I've written in the first message so it is OK if things stay the way they are.
My intent was to understand if there was a will to expose "current tab" information in a subsequent release.
from elm-bootstrap.
It's a bummer this was closed because I'm facing the same issue, where I'd like to fire a Cmd when changing to a specific tab, and since Tab.State
is opaque, there isn't a way to query the activeState inside it.
from elm-bootstrap.
Related Issues (20)
- Progress bar height attribute should be in the wrapper
- Vertical Buttongroups should use only class "btn-group-vertical"
- Website on v5.0.0 docs HOT 1
- Radio buttons using ... buttons?
- Form.Range is not exposed in elm.json file HOT 2
- Modal header "close" button should have `type="button"`
- Config Bootstrap.Navbar.collapseSmall
- Cannot use Flex HOT 1
- Modal Scrollable Body config does not actually work
- Error in documentation for Pagination
- attrs is not exposed by Alert
- Block.text in a single line
- No option to hide the NavBar Menu after Clicking a Menu item HOT 3
- Spinner.spinner does not work with bootstrap 4.0.0
- Support .form-row
- Clicking on the navbar dropdown menu changes the current url
- How to create Navbar submenus? HOT 2
- Any plan to upgrade to Bootstrap 5 ?
- No backdrop on second modal
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 elm-bootstrap.