How create gmail like common control bar in Canjs? - canjs

For example we make a Gmail clone in canjs. Consider each item in the sidebar being rendered with a component of its own. Now I want a single control bar just like gmail to control the activities inside the components.
How should I approach it???
At present am looking at the change event of localStorage, is there a better solution to this???

I would recommend using an appstate Map or a page level component that holds the state for the features of your toolbar. If using an appstate, you could use can.route.map to bind certain features of the appstate Map to the route, so the state of your app can be controlled by the URL. A page attribute, for example, would control which main page is displayed (say, the message list or the contacts list.) You could then listen for certain values of page in your stache template to switch to showing the correct page. This snippet would show the message-list whenever the page attribute of the appstate is 'messages': {{#is appstate.page 'messages}}<message-list></message-list>{{/is}}
If you had more specifics of which feature is hardest to figure out how to implement, I might be able to give more specific advice.

Related

React flux mouse position resets when store emits a change

I have a page that displays a list of articles. Users will be browsing to the end of the page and click on "load more" to trigger an Action that loads more articles into the list inside the Store. But the react component kind of re-renders the entire page so my viewport resets to the top of the page.
Anyone know how I can solve this? Thanks.
p.s: the architecture is React Flux
Take a look at adding a key to each of your components. React will re-draw everything unless it knows that certain components haven't changed and so don't need redrawing.
That would be my guess, based on the information provided.

Kendo UI - using history.replaceState to manage back stack / back button navigation

I have a Kendo UI application flow where I don't want the user to be able to step back into a particular set of views (ie, a couple of 'create' views that lead to the 'completed record' view - the user should not re-access those specific create views). This is for a mobile app if that makes a difference.
I know that Kendo can use window.history features to some degree, but it looks like they have only implemented pushState (http://docs.telerik.com/kendo-ui/api/javascript/router#configuration-pushState), but I believe I would need the replaceState method.
Is there a way to take some manual control temporarily without breaking off from the back stack/backbutton widget?
Turns out that Kendo has an implementation of replaceState that they have abstracted to replace. See doc here.
It's as simple as calling your next destination.
kendo.mobile.application.replace("#baz");
kendo.mobile.application.navigate("#baz");

Wicket - Save current layout / view

I have an application in which I would like the user to 'save the view'. I.e. I make heavy use of ajax to replace all kinds of Panel and use nested jQuery UI Layout plugin for 'frames'.
So basically, the view is defined as the (functional) tree of components, combined with the Javascript state of the jquery plugin, combined with the 'query' a user has given.
I'm wondering what would be a good strategy to save this view state, and how to load it again.
I though of keeping a sort of UIState-model on the page level, and pass it to all components. The components then use specific settings of this model to initialize themselves and changes in the components should be reflected back into this state model.
However, this gets complicated when a Panel is reused in several places. The reason is that a component needs, besides its knowing how to read its own state from the central modal, also take into account the location in the (functional) hierarchy of components.
What would be a good approach? Has anyone done something similar?

Updating Controls from Multiple Pages on Windows Phone

All, I am new to Windows 7 Phone. My situation is that I have a main page which contains a ScrollViewer which in turn houses a StackPanel. I want to populate this StackPanel with multiple sub-StackPanels (at runtime) which are to hold an Image Thumb nail a hyperlink and some basic information about the image.
This is all good when I do this from the main page, but I want to know how to update this control (which is on the main page), but from any page other than the main page. I would like to know what is considered best practice for updating a page's control (like that outlined above) from another page.
Obviously there are a number of ways to pass data between pages
PhoneApplicationService.Current.State["yourparam"] = param
NavigationService.Navigate(new Uri("/view/Page.xaml", UriKind.Relative));
then in other page simply
var k = PhoneApplicationService.Current.State["yourparam"];
and many others. But what is best practice for updating a generic control from a different page?
Note: There are many question about data access and passing between pages.
Passing data from page to page
How to pass the image value in one xaml page to another xaml page in windows phone 7?
Passing image from one page to another windows phone 7
and more. This is not what I am asking.
If I understand your question correctly, you are trying to update a control which is on for example MainPage.xaml from another page for example Page2.xaml.
As far as I know there is no way to reach a pages controls from another page, and that seems unnecessary for the cases that I can think of.
The method used to achieve what you are trying is usually done by triggering an action (like the press of a button ) and passing a parameter to the page you are trying to update the control. And on that page's onnavigatedto event (or viewmodel constructor if you are using the MVVM pattern), update your control based on the passed parameter.
If your update is based on data then the best practice is to bind an observable collection or an object that extends the INotifyPropertyChanged (basically any object that can signal that one of their property changed to the ui) and change the data based on the parameter that is passed.
If these two pages somehow are visible at the same time and there is no navigation needed between them( like a popup or sliding menu kind of ui) then you can make the page that you are showing in the popup a usercontrol, and reach to the parent's controls by this.Parent.
I can be more helpful if you give more specifics about your app's flow.
The MVVM pattern would be a good way to go. Saying MVVM is too complicated for small teams isn't exactly accurate - the purpose of MVVM is to decouple Silverlight or WPF code. Using the codebehind of a Silverlight page to directly access data creates coupling in your code and accrues technical debt. Whether you're one developer or 100, if your UI is coupled with your data classes, if you have to change your data classes, you will have to make changes to every UI element that uses those classes. This takes longer and makes your application more difficult to change.
MVVM makes it so your UI (the View) doesn't know anything about the data (your Model). The ViewModel is the code in between that the UI can bind to, and which manages events in the UI that need to be persisted to the Model, and also changes in the Model that need to be represented in the View. For this reason, it handles events, and that's what it sounds like you need in your code - an event that can exist off of the codebehind, that can update the Views bound to it when the data changes. If you have two pages, then an event on one of the pages will be sent to the ViewModel, which will make a change to the Model (data) if necessary, and pass it back to the ViewModel. The ViewModel would then update any of the UI elements (Views) bound to that piece of data.
There's a REALLY good demonstration of how to implement the MVVM design pattern here
. The guy goes through and takes a typical WPF application (just like Silverlight), where the UI codebehind implements event handlers that directly access data, and refactors it using the MVVM pattern.

how we use pageindiactor in pivot

i want to use page indicator control in pivot ,to show the user which page they attract.but i also want to add some functionality in page indicator to select the page with the help of page indicator like android .but i don't know how it is possible.if u know then send me a link or example
You could create the ui yourself and update the current page indicator by using the selectedIndex property. There are controls created by other developers, like here, which you could use. But for complete control over the functionality, I'd suggest you create your own or use the source code provided by other developers (see above link) to get ideas.
To make the implementation clearer:
You can add the same UIElement containing a list of dots equal to the number of pivots, and using the SelectedIndex property you can fill the corresponding dot. Add gesture events to this element and handle it to change the SelectedIndex appropriately.

Resources