CXJS how to confirm to leave an routed link url? - cxjs

Take the standard dashboard starter app: https://cxjs.io/quickstart . Click in the left menu from "page" to "page".
How can i prevent unloading a content component with an onblur confirm?
in the controller ondestroy seems not to work.
thanks!

This is not currently supported, but it would be a great feature.
https://github.com/codaxy/cxjs/issues/408

Related

Ionic- need an event after page is backed

I need an event of page which is backed.
IonWillEnter or ionViewDiEnter events aren't fired when page is backed.
Ionic framework seems to show page simply when a back button is clicked.
Would you like to teach me?
Sorry for my poor English.
Thanks
For your info.. Ionic 2 lifecycle method
ionViewDidLoad - works the same way as ngOnInit, fires once when the view is
initially loaded into the DOM
ionViewWillEnter and ionViewDidEnter - hooks that are available before and after the page becomes active
ionViewWillLeave and ionViewDidLeave - hooks that are available before and after the page leaves the viewport
ionViewWillUnload - is available before the page is removed from the DOM
You should use ionViewWillLeave / ioniViewDidLeave to track the page back/close event
According to https://ionicframework.com/blog/navigating-lifecycle-events/
ionViewWillEnter: It’s fired when entering a page, before it becomes the active one. Use it for tasks you want to do every time you enter in the view (setting event listeners, updating a table, etc.).
ionViewDidEnter: Fired when entering a page, after it becomes the active page. Quite similar to the previous one.
So you can use any of above. I prefer ionViewDidEnter more in this scenario so screen render faster if you call any API.

Breadcrumb doesn't work on a component I created (Joomla!)

I'm learning how to use Joomla! 3.2
I created a new component, then I added it to my main menu,
Here are the only parameters I changed in the main menu:
But now when I go to my new component the breadcrumb doesn't work correctly, there's only the home button and when I click on it I'm redirected to the same page:
Did i missed something very important? How can I fix it? The breadcrumb works on every other pages.
Ok I found the problem, I forgot to add this
$pathway = $app->getPathway();
$breadcrumb = $pathway->setPathway(array());
$pathway->addItem( JText::_( 'COM_PARTISPOLITIQUES' ),JRoute::_('index.php?option=com_partispolitiques&view=partispolitique'));
$pathway->addItem( "Current page name",'');
In the file view.html.php located in my component folder...
I am going to assume you are using the Helix template as it seems to be a common oversight.
Make sure that Enable Page Title is enabled from your menu Helix Page Title tab.
If not, please advise as to what template.

Long press an element to show the black options bubble(copy,forward..) like wtsapp?

Can someone point me to the right direction of how to show options(copy, forward...) when I long press an element (a message in this case) like wtsapp/FB messenger?
I don't even know what keywords should I be searching...(tried modal, popover, action sheet)
Thanks.
Update:
I understand that I should use the on-hold gesture...I am specifically looking for the black option bubble to be shown. I don't know what it is called(not modal/pop up/ action sheet/popover/alert). Thanks.
you can use on-hold="myFunction()", check the link below
http://ionicframework.com/docs/api/directive/onHold/
and then use the $ionicActionSheet Service to do your logic, check the link below
http://ionicframework.com/docs/api/service/$ionicActionSheet/
on-hold event is your friend : http://ionicframework.com/docs/api/directive/onHold/
I think following Codepen example would help in accomplishing what you want to do:
Actionsheet : http://codepen.io/ionic/pen/jLylA
Also, have a look this thread on Ionic Forum before you start implementing, just to avoid any similar issue, plus, this thread got some CodePen examples, that your might find useful :
https://forum.ionicframework.com/t/displaying-actionsheet-on-a-long-press-aka-hold-event-problem/5663
You can implement long press with either on-hold and if you want to implement long press for buttons, try this directive from this link and a note on directive can be found here . You may need to use a custom action sheet ($ionicActionSheet) to implement the UIMenuController (iOS component) like feature.
.selectable{
-webkit-user-select: auto;
}
for selection and ion-content to overflow-scroll="true"

Opening URI in overlay, not main page

On my page, overlays are loaded by inserting their content with jQuery and then fading in.
What I want to do is this:
When you click to open an overlay, an URI is loaded (e.g. news/12, where news is the category and 12 is the id of the item to load).
Except, instead of loading it in body, it should be loaded in the overlay.
In other words, I want to achieve something like on facebook, where you open an overlay, the url changes, but the main page stays the same.
I'm guessing you need ajax for this, but I have no idea whatsoever how to do it.
Thanks
It sounds like you want to use the new history.pushState(...) and history.popState(...) browser API.
This SO post might help you out: Change the URL in the browser without loading the new page using JavaScript
Use Boxy. See http://onehackoranother.com/projects/jquery/boxy/tests.html#
AJAX example:
<a href='#' onclick='Boxy.load("test-1.html");'>Test 1</a>
See this question: Ajax - How to change URL by content
I solved it thanks to Lethargy's answer.
.pushState() is exactly what I need to have the URL reflect the contents of the overlay that is dynamically created with jQuery.
With some tweaking around and debugging I managed to get it all working.
Now my overlays (or popups, dialogs, whatever) are search engine ready, and the url is copy-pastable for users :)

avoid chrome popup extension to close

Is there a function that allow me to select text when the extension
stays open. Normally when I Use the extension popup and I Click outside the
extension the extension close. Is there a wat to avoid this.
Thank you so much
Unfortunately there is currently no way to keep the popup open once you focus out of it. This is by design.
If you would like to always show something while interacting with the page, perhaps the experimental Info bars or even Desktop Notifications would work?
Hope that helped!
The only way to keep it open is to right click over the extension icon (button) and select "Inspect popup" the extension popup then show up and remain open but of course the debugger window show and this not a fix obviously still it will maybe inspire a hack... if someone is skilled enough and share the solution with all of us.
I encountered the same problem and I've thought of a possible solution (though not tested it):
Use your background.html to store the content of the popup action and upon loading the popup, you fetch the content via the default messaging for chrome extensions.
When doing all kinds of other stuff, like XHR's or something, I think you should do that in background.html too, so the requests won't abort if you close and you can do something with the result. Then when a user re-opens the popup, he'll see the result of his previous action instead of the default screen.
Anyone tried something like did already?
As far as I know you can't persist a pop up menu but my workaround has been using a content script to append a menu on page load. After the menu is appended you can toggle the menu via messaging between the background script and the content script.
If you want to encapsulate the menu from the page it's deployed on you could wrap your menu in an iframe. This could add complexity to your project since you would have to deal with cross origin issues and permissions.
There is an alternative hack for this. You can make use of chrome local storage to store the metadata as needed. Upon restart you can read that metadata and render the desired content. You will also probably clear that metadata after you have completed performing the operations based on that.