How to avoid multiple pages to open on quick taps of thumbnail on devices - ionic-framework

I have an ionic application which has movies menu. On click of movies menu navigates to movies list in thumbnails. On click on any thumbnail navigates to its details page. But on quick taps opens multiple movie details pages equal to number of taps.
I tried adding a flag and a promise. But doesn't seem to work.
isTapped = false // by default
// Below code is executed
this.isTapped = true;
this.moviesFeedsService.getMovieDetails(asset.asset_id).subscribe
((msuMovieDetails) => {
this.navCtrl.push(
MediaDetailsPage,
{
headerDataTitle: this.headerData.title,
movieDetails: msuMovieDetails,
showEpisode: this.featureLayoutData.showEpisodes
},
navOptions
).then(() => {
this.isTapped = false; // Reset flag
});
});
Expected : On tapping even multiple times page instance opened should be single
Actual : Multiple instances of page is opened on quick taps

Related

How can I auto-hide/open panels in Unity with multiple buttons?

I have tried to find solutions but somehow I can't find the right solution for my problem. I have 5 buttons and each button opens or closes its panel. However, I want that if I click on Button 2 that the panel closes for Button 1 and so. There should be only one panel active for each button.
It is just having a tab menu you are clicking through, only the panel of the last pressed button is active. I have seen a tutorial with images and Eventsystems but does not fit my current project.
I would be grateful for any help.
You can create a list for panels and in the same order add buttons to the another list. Respective button and panel in same places. Then when you press a button get index it in script. Activate matching panel index and disable others. In my script, I don't want to disable panels because I need to those script to run everytime. In your case you can just disable them.
for (int i = 0; i < panels.Count; i++)
{
if (i == index)
{
panels[i].GetComponent<CanvasGroup>().interactable = true;
panels[i].GetComponent<CanvasGroup>().alpha = 1;
panels[i].GetComponent<CanvasGroup>().blocksRaycasts = true;
// Place to front for interaction
panels[i].transform.SetAsLastSibling();
}
else
{
panels[i].GetComponent<CanvasGroup>().interactable = false;
panels[i].GetComponent<CanvasGroup>().alpha = 0;
panels[i].GetComponent<CanvasGroup>().blocksRaycasts = false;
}
}

ionic 4 routerOutlet.canGoBack() returns false when navigating with navigateForward

I have a button in my ionic application to open a article from the homepage. I want to enable my users to exit the app by pressing the device back button. But when they are at the article page I want it to just go back to the homepage when pressing the back button.
I created a custom backbutton event to handle the function of exiting the app. It can exit the app from the homepage. However when pressing the back button on the article page, it does not navigate back to the homepage and nothing happens. How can I make it goes back to the homepage from the article page when pressing the back button?
In app.component.ts
this.platform.backButton.subscribeWithPriority(99, async () => {
if (this.routerOutlet && this.routerOutlet.canGoBack()) {
this.routerOutlet.pop();
} else if (this.router.url === '/home') {
navigator['app'].exitApp();
}
});
I noticed that this.routerOutlet.canGoBack returns false when firing the event from the article page, so the routerOutlet.pop() is not fired. Not sure if this is to do with how I open the article page?
This is how i open the article page
viewArticle(articleId) {
let navigationExtras: NavigationExtras = {
state: {
articleId: articleId
}
};
this.navController.navigateForward(['/article'], navigationExtras);
}

In NativeScript, how do I change page/view in a modal page?

I would like to create a multiple step modal dialog - like a wizard. A series of screens that follow on from one another.
I'm using the code from NativeScript's site to display a modal (https://docs.nativescript.org/core-concepts/navigation#modal-pages)
var modalPageModule = "./modal-views-demo/login-page";
var context = "some custom context";
var fullscreen = true;
mainPage.showModal(modalPageModule, context, function closeCallback(username, password) {
// Log the user in...
}, fullscreen);
The code works, but I'm unsure how to change the modalPageModule once the modal is displayed.
Possible duplicate
Nativescript: How to use navigation in modals
https://github.com/NativeScript/NativeScript/issues/3753

jQuery Mobile checkbox takes time to get checked/unchecked on iPhone

I am facing an issue with jQuery Mobile on iPhone.
I have a list of checboxes and a checkbox to select "All".
After an initial few taps on the checkbox, the check box takes few seconds to get marked as checked/unchecked.
The checkbox doesnt get marked unless the user waits for a few seconds or scroll the screen.
This seems to be an issue only with this particular phone as it works fine on desktop browsers and Android devices.
Here is the script:
/* Check-Uncheck */
self.elements.listview.on('change', ':checkbox', function (event) {
var unchecked = $(':checkbox:not(:checked)', self.elements.listview);
self.elements.selectAll
.prop('checked', unchecked.length === 0)
.checkboxradio("refresh");
});
/* Check-Uncheck 'Select All' */
self.elements.selectAll.change(function () {
var checkboxes = $(':checkbox', self.elements.listview);
var checked = self.elements.selectAll.is(':checked');
checkboxes
.prop('checked', checked)
.checkboxradio("refresh");
});
Please let me know if anyone has faced this particular issue, or have any suggestions.
Thanks

webworks blackberry 10 window.open twitter facebook

i am just trying to implement facebook and twitter in my Webworks App and cannot get them work together.
I am using the FaceBook-OAuth-2 and the Twitter-OAuth-1 sample and i just put both stuff together and my problem is that only the first startOAuth() opens a window in the app to login the second doesn't so if i first clicked facebook it works after when i try twitter nothing happens.
https://github.com/blackberry/BB10-WebWorks-Samples
thanks
function setClickHandlers() {
console.log('set click handlers');
var fb = document.getElementById('facebookOn');
fb.addEventListener('click', function(e) {
// if the childWindow is already open, don't allow user to click the button
if(childWindow !== null) {
return false;
}
e.preventDefault();
toast('Contacting Facebook...');
setTimeout(function() {
startOAuth();
}, 500);
});
console.log('set twitter click handlers');
var tw = document.getElementById('twitterOn');
tw.addEventListener('click', function(e) {
// if the childWindow is already open, don't allow user to click the button
if(childWindow !== null) {
return false;
}
e.preventDefault();
toast('Fetching access token...');
setTimeout(function() {
twittergetAccessToken();
}, 500);
});
}
I would start by adding some debug code in your click handler to see if that's getting called when you click the button in the first place.
If it is, then I recommended you use Web Inspector (console) to see if there are any errors. If there are, they'll show up there.
Good reference for Web Inspector here - http://developer.blackberry.com/html5/documentation/web_inspector_overview_1553586_11.html
If the click handler is not being fired then perhaps you have the wrong element ID, or the setClickHandlers function is not being executed.