https://github.com/quickcorp/qcobjects-view-stack-widget-example
https://github.com/quickcorp/qcobjects-view-stack-widget-example
Last synced: 4 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/quickcorp/qcobjects-view-stack-widget-example
- Owner: QuickCorp
- Created: 2021-04-17T03:16:33.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2021-04-17T03:59:36.000Z (about 5 years ago)
- Last Synced: 2025-06-21T08:36:09.917Z (12 months ago)
- Language: HTML
- Size: 6.84 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Tutorial: A View Stack Widget Using QCObjects
## Step 1:
Create three files: view-stack.html. one.html, two.html
## Step 2:
Iside the file index.html include the following tag in the head section:
```html
```
## Step 3:
In the body section, add the following:
```html
This is a view stack example
There are 3 files, view-stack.html , one.html and two.html
This part of the page (index.html) does not change when you click in a link
Open DevTools in your browser (second mouse button, click on Inspect Elements) and see what happens with the elements of this page when you click a link
```
## Step 4:
Give some style to your component
```html
component[name=view-stack]{
border: 1px solid black;
width: 200px;
height: 200px;
position: relative;
display: block;
padding: 0;
}
```
## Step 5
Create a CustomComponent class to define the custom behaviour when a view is loaded
```javascript
CONFIG.set("routingWay", "pathname")
Class ("CustomComponent", Component, {
_new_ (o){
var component = this;
component.addComponentHelper(function (){
component.__promise__.then(function (){
// This shows a notification when the content of the current page is fully loaded into the view stack
return Promise.resolve(NotificationComponent.success(`Current View is ${component.routingSelected.pop().name}`));
}).catch (function (e){
return Promise.resolve(NotificationComponent.danger("some problem"));
})
});
_super_("Component", "_new_").call(this, o);
}
});
RegisterWidget("view-stack")
```
## The complete code looks like this
```html
component[name=view-stack]{
border: 1px solid black;
width: 200px;
height: 200px;
position: relative;
display: block;
padding: 0;
}
This is a view stack example
There are 3 files, view-stack.html , one.html and two.html
This part of the page (index.html) does not change when you click in a link
Open DevTools in your browser (second mouse button, click on Inspect Elements) and see what happens with the elements of this page when you click a link
CONFIG.set("routingWay", "pathname")
Class ("CustomComponent", Component, {
_new_ (o){
var component = this;
component.addComponentHelper(function (){
component.__promise__.then(function (){
// This shows a notification when the content of the current page is fully loaded into the view stack
return Promise.resolve(NotificationComponent.success(`Current View is ${component.routingSelected.pop().name}`));
}).catch (function (e){
return Promise.resolve(NotificationComponent.danger("some problem"));
})
});
_super_("Component", "_new_").call(this, o);
}
});
RegisterWidget("view-stack")
```
See this example running on glitch [index.html](https://heavenly-grave-challenge.glitch.me)