how to use the native control plugin in PhoneGap to load a different page into the UIWebView - uiwebview

I'm using the NativeControls plugin to create a tabbar - http://d.pr/vBJZ
Apparently, on first load, the tabbar has the onSelect event attached to them and i can refresh the webview just fine by doing window.location="http://someremotedomain.com".
But once the webview refreshed with the new external page - it seems the tabbar loses its onSelect event.
I suppose my real question is - why does the tabbar buttons loses its onSelect Event when the webbview starts to show a different (remote/external)page?
Does that mean that i have to re initialize the NativeControls on every new page? that isn't possible because the page im showing is coming from an external source, which doesn't include the phonegaps js related files.
My 2nd question - probably would help me dilemma, is there any way to grab the UIWebView control?

okay nevermind i figured out:
the javascript callback function doesn't exist anymore on the next page
yes you can - but i don't know in the js file but in the plugin/obj-c you can access the webview

Related

Customized error message on loading error of PDF in PDFTron

I am working with PDFTron - WebViewer,
Want to know how to handle PDF loading errors and showing customized message, in case of web-viewer
Regards
Bhupesh
The easiest way to do this right now is to modify the ErrorModal component in the UI and replace the error messages there. You'll need to string match the old message and replace it with your own.
The component is located at ui/src/components/ErrorModal/ErrorModal.js and you'll want to change the onError function.
This link describes more about how to edit and build the UI https://www.pdftron.com/documentation/web/guides/ui/advanced-customization
WebViewer has methods that let you display a modal Warning message box, which can be dismissed with its Confirm button or a click outside the dialog, or you can display a modal Error box which has no dismiss buttons and requires you to hit [F5] to refresh the page.
https://www.pdftron.com/api/web/UI.html#.showWarningMessage
https://www.pdftron.com/api/web/UI.html#.displayErrorMessage
Using these is more straightforward than editing the UI code from the pdftron github repo.

Displaying Extension Library Dialog box when page loads?

Is there any way to display an extension pages dialog box when my page loads?
Add a <xp:scriptBlock /> with the following client-side code as its value:
XSP.addOnLoad(function(){XSP.openDialog("#{id:dlgMessage}");});
...just be sure to place the component outside any refresh targets, or it will launch the dialog again after every partial refresh event with a target that includes it.
Try adding a dojo.addOnLoad() (in a xp:scriptblock) that displays the dialog using CSJS: XSP.openDialog()
Bruce,
You could use jQuery to 'push' the button on page load.
Try putting this clientside js code in your onClientLoad event
$(document).ready(function(){
$('a.btn').trigger('click');
});
You will have to load jQuery to use this if you don't already have it loaded. You might also be able to do the same thing with dojo.
EDIT: You might have to modify the selector (the tag and class in the parens line 2) above if not using bootstrap. I would give it a unique class so as not to 'push' any other buttons at the same time.

Pagination inside bootstrap modal window

I am using the bootstrap modal window as data picker. But when having more results to pick displaying pagination. I want to load the next pages inside the same modal window when clicking on the pagination.
Can I do it in generic way like when any link clicked inside a modal window to load the content inside the same modal window, or do I need to implement this for each link separately using AJAX feature?
Please refer this three links: There will help you for sure.
Reference-1
Reference-2
Reference-3
You could change $('modal-body').html() on click.
The modal shows/hide without changing or reloading content. So you will have to restore the original content on hide maybe.
Use $('#myModal').on('hidden.bs.modal', function () {} to restore your original content.

jQuery Mobile - Dialogs without changing hash

I have a search dialog that I am popping up and filling with jquery templates. After they make a selection I set a value on the current page. As such I don't need hashTags or anything like that, I just need a pop-up dialog that I can open and close programatically. I am currently opening the dialog with
$.mobile.changePage(dialog, { transition: "slide", changeHash: false });
and closing it with
dialog.dialog('close');
However, in certain cases (when the page is navigated to), closing the dialog refreshes the current page.
Is there a better way to interact with this?
Update:
I think I figured out what is going on. So for some reason, jquery mobile usually keeps 2 pages loaded on the DOM - one of which is invisible, you can verify this by running $('[data-role=page]') in the console. One page is the page you're on, the other is the page that you initially navigated to. Not quite sure why they choose to do that, but there you have it.
So they treat dialogs as a page navigation with a different transition even if the dialog is already in the DOM. Therefore, if you go directly to the page and then trigger a dialog, modifying the current page and closing it works fine - because the original page is always loaded in the DOM. However if you go to another page, than navigate to the page that triggers the dialog, and THEN trigger the dialog it destroys the current page so that the pages in the DOM are the initial one and the dialog. In that case it reloads that dialog-launching page entirely and you never get a chance to make any modifications.
Jeez. How do I interact with the jqm dialog widget directly?
You can try two other things. Both should work:
1 set DomChache
How about overriding JQM to keep the page your are firing the dialog from in the DOM? The docs say you can set data-dom-chache and override cleaning the page from the DOM.
If it only happens when you load this page in via AJAX (vs. loading it directly) you could make DOM-keeping dependend on your trigger page having data-page-external, assign DOM-chache="true" only when the dialog is openend and remove it again once the dialog is closed.
2 override JQM
I had the same problem you described and got it to work like this (requires hacking into JQM though...):
// inside transitionPages function
if ( !$(toPage).jqmData('internal-page')
{fromPage.data( "page" )._trigger( "hide", null, { nextPage: toPage } );}
}
My problem was that pagechanging to certain pages (same as dialog) caused the preceding page (where the dialog fired from) to be removed from the DOM, so I had a blank screen (when trying to go back). I added data-internal-page="true" to the pages, which should keep the preceding page intact and added the if-clause in JQM.
So now pageHide (and DOMcleanup) only fires, if I'm not going to a page labelled with data-internal-page="true"
Cheers!
I think I was having a similar problem. What I wanted to do was based on certain parameters, pop a dialog window on load (with that content on the same page), which they can close and view the page that loaded.
I could get it to pop on load using load, or the pageshow events, but when I clicked close that sent you back to the previous page in history, instead of just closing the dialog.
//target your 1st page content, here its id=success
//the modal content is in a page id=dialog and data-role="dialog"
$('#success').live('pageshow',function(){
window.setTimeout(function(){
$.mobile.changePage('#dialog','pop',false,false);
},1);
}
Its a hack, and just allows the page load to beat the dialog so it gets stuck in history. Then the default dialog close behavior for the dialog works as expected. Talk about a PITA, if they took a little more for the JQuery UI dialog it would have made things a ton easier.
And regarding your question: Have you looked at Jquery Mobile Actionsheet plugin
If you don't really require a page to be loaded, that should be ok.
Also helpful could be Cagintranet iPad popover, although you have to tweak the design to be fullscreen on mobile devices. If you require CSS/Jquery to do that let me know (I'm using this in a JQM plugin I'm writing)
Hope that helps.

Using multiple UIWebViews in a UIScrollView

I am using 5 UIWebViews in a UIScrollView to show the result of my game. Intention is to allow the user to scroll through the results screen. I had a problem where the UIWebViews won't load when scrolled to the next page. This means the first page will load successfully however when you scroll to Page 2, you will see a white blank page. Page is loaded as I can see the alert which was given in all the 5 pages, but it won't show.
I tried a workaround as mentioned here
inserting various views into UIScrollView
http://pinchzoom.com/blog/items/view/1386/one-of-the-problems-with-the-uikit-at-the-moment-is-an-issue-embedding-a-uiwebview-within-a-table
This fixed my problem, however when I submitted the app to iTunes, it got rejected with the following comment.
"3.3.1 Applications may only use Documented APIs in the manner prescribed by Apple and must not use or call any private APIs."
The non-public API that is included in your application is _documentView
I would like to fix this issue and resubmit. Can someone help please ?
Thanks
Jugs
Just use one WebView for all results (which will scroll if it doesn't fit into the screen).

Resources