Skip to content

Instantly share code, notes, and snippets.

Avatar

Adrián Ribao AdrianRibao

View GitHub Profile
View final_view_function.elm
renderHeaders : Tabs -> Html Msg
renderHeaders currentTab =
ul [ class "nav nav-tabs" ]
[ li [ class "nav-item" ]
[ a
[ class "nav-link"
, onClick (ChangeTab Step1)
, classList [ ( "active", currentTab == Step1 ) ]
]
[ text "Step 1" ]
View render_headers_click.elm
enderHeaders : Tabs -> Html Msg
renderHeaders currentTab =
ul [ class "nav nav-tabs" ]
[ li [ class "nav-item" ]
[ a
[ class "nav-link"
, onClick (ChangeTab Step1)
]
[ text "Step 1" ]
]
View update_tab.elm
update : Msg -> Model -> Model
update msg model =
case msg of
ChangeTab tab ->
{ model | currentTab = tab }
View render_content.elm
renderTabContent : Tabs -> Html Msg
renderTabContent currentTab =
case currentTab of
Step1 ->
div [] [ text "Content for tab1" ]
Step2 ->
div [] [ text "Content for tab2" ]
Step3 ->
View redner_headers.elm
renderHeaders : Tabs -> Html Msg
renderHeaders currentTab =
ul [ class "nav nav-tabs" ]
[ li [ class "nav-item" ]
[ a
[ class "nav-link"
]
[ text "Step 1" ]
]
, li [ class "nav-item" ]
View main_tab_views.elm
view : Model -> Html Msg
view model =
div []
[ renderHeaders model.currentTab
, renderTabContent model.currentTab
]
View model_tabs.elm
type alias Model =
{ currentTab : Tabs }
-- Don't forget to setup the initial values for the model. In our case we wan't the app load the first step.
initialModel : Model
initialModel =
{ currentTab = Step1 }
View tab_type.elm
type Tabs
= Step1
| Step2
| Step3
@AdrianRibao
AdrianRibao / elm_javascript.js
Last active Jan 23, 2016
Sending url from javascript and perform an http request
View elm_javascript.js
let Elm = require('../../elm/cvs/cvs.elm');
$(document).ready(function(){
$("#cvs-search-form").submit(function(event){
let params = $(this).serializeArray();
let querystring = $.param(params);
let composed_url = `${this.baseURI}?${querystring}`;
cvs.ports.getURL.send(composed_url);
event.preventDefault();