Hello!!
i have a question and i haven't found any solution for it anywhere...
So, I have a button that link to internal div page (#page2) with a very long list, I need that the internal div page will be "loaded" before the transition will start...
Here is a very simple Sample Code:
<!-- Page #1 -->
<!-- ... -->
<div data-role="content">
<p>View internal page: goto Page 2</p>
</div>
<!-- ... -->
<!-- Start of Page #2 -->
<div data-role="page" id="page2">
<div data-role="header">
<h1>Bar</h1>
</div><!-- /header -->
<div data-role="content">
<ul><li>...</li>
<li>...</li>
<!-- About 300+ of: <li>...</li> -->
</ul>
</div>
So, Clicking over The link to #page2 should give you jquery mobile "Loading..." And after it "loaded" the content the transition should begin..
The reason Im doing it in the same page it that im inserting to the page#2 div dynamically all facebook friends (Long list), and it take a long time from the Click and until the transition begin...
Here is a nice example of what i need:
http://www.mpdtunes.com
Just go to: Live Demo-> Login -> Click Artists...
Any suggestions are welcome!
Thank you very much!!!!
Basically you want to do this:
Use button like this:
goto Page 2
Add a click event to it:
$(document).on('pagebeforeshow', '#index', function(){
$(document).on('click', '#to-page2', function(){
// Load internal page content
});
});
Where #index is an id of your button containing page.
Show loading animation aka ajax loader
setTimeout(function(){
$.mobile.loading('show');
},1);
SetTimeout is needed because web-kit browsers have a problem with dynamically triggered ajax loader.
Load your internal page content. Now if you are using 1 HTML page with multiple pages you can append new content to listview immediately. This is because listview is already loaded into the DOM. If you are using several HTML pages then store your page content into localstorage variable.
Hide ajax loader, again with setTimeout.
Start page transition with:
$.mobile.changePage("#page2");
If you have 1 HTML page then this is it. If you have stored your page content inside a localstorage then you will need to load it during the pagebeforeshow event of a second page, like this:
$(document).on('pagebeforeshow', '#page2', function(){
// Load internal page content from local-storage and append it
});
Last step is listview page content initialization. For that look at my other answer, just look for a topic regarding listview.
Related
I have a nested HTML page as:
<html>
<body>
<div class="container">
<nav class="item_list">...</nav>
<article id="item_details">
<object type="text/html" data="detailsPage?key=document1">
<html>...</html>
</object>
</article>
</div>
</body>
</html>
Inside the main div (class="container") there's a item list on the left (nav class="item_list"). On the right side, it is an article with id item_details. Inside the article, it is a nested html page which shows the details of a selected item. In the nested html page, there's a form to add new item or delete an existing item. This action needs to refresh the nav part.
So my question is - how to refresh the nav part in response of a button click from the nested HTML page? More specifically, I'm using Vert.x as my server application toolkit, it the resolution is by Vert.X, it will be much more helpful.
Thanks in advance.
refresh the nav part in response of a button click from the nested HTML page?
Attach a button click listener as a javascript function
In that function make a request to your vert.x backend with the appropriate data
Return the new nav response you want from your vert.x backend
Use that data in javascript to refresh the nav part
Ps This has nothing to do with vert.x and is regular webapp design patterns
I have three pages/documents in my web page. The links to these pages/documents are provided in left navigation.
I am planning to add Skip to main content in angular UI header. So this will be a common skip link for all 3 pages.
Clicking on skip link from page 1 should take me to Main content of page 1.
Clicking on skip link from page 2 should take me to Main content of page 2.
Clicking on skip link from page 3 should take me to Main content of page 3.
So I have written a condition in my .ts file which will take to the respective main-content. But clicking on Skip to main link is working only once (focus moves to main-content landmark), but from next time the link is not working repeatedly. Am I missing something to make sure that the skip link is working multiple times on enter/click.
I am new to Angular, so please let me know if you need any additional details to understand my requirement.
.ts file
goToMainArea() {
if (location.href.substring(location.href.lastIndexOf('#') + 1) != "mainarea") {
location.href += "#mainarea";
}
}
Partial required HTML code:
<div class="ABC header d-flex" role="banner">
<div class="skip-link">
<a (click)="goToMainArea()" tabindex="0">Skip to main content</a>
</div>
<div class="inventory-title">
<span>
<a [routerLink]="['/home']" attr.ngbTooltip="Home" class="showLink"><span class="titleMaximized">ABC</span><span class="titleMinimized">A</span></a>
</span>
</div>
I'm in the process of updating my website and I am trying to optimise the website as much as possible. One of the things I'm trying to do is remove excess text and duplicate text/code.
I have around 20 pages and each page includes a button that pops up my privacy policy using the function below.
The page also imports .css for the pop up which includes mark up and script.
<!-- Begin Footer -->
<div class="mainText">
//site name etc
</div>
<div class="popup" onclick="myFunction()">
<div class="privacyButton">
Privacy Policy
</div>
<span class="popuptext" id="myPopup">
<!-- Policy Content -->
//html content like <p></p> and <strong> etc</strong>.
<!-- End of Policy Content -->
</span>
</div>
<script>
// When the user clicks on div, open the popup
function myFunction() {
var popup = document.getElementById("myPopup");
popup.classList.toggle("show");
}
</script>
<!-- End of Footer -->
How can I place this in a separate file and load it from the external file to save me having so much text on every page?
I've tried THIS to use a jQuery, but it doesn't work because of the nature of the pop up.
I've also tried placing only the content (which would still be better than nothing)
<!-- Policy Content -->
//html content like <p></p> and <strong> etc.
<!-- End of Policy Content -->
...in a separate .html file using
<link rel="import" href="/movedContent.html">
...but upon loading, it doesn't adopt the css from the popuptext class.
I'm unsure where to go from here or what to include in any external file in order for importing this on each page. Thanks.
I am using a cms which has a page where new content is added via ajax.
So the content is constantly updating but there are no page refreshes.
This is typically the html for each piece of content which gets added.
<li class="row-1" style="display: block;">
<div class="content">
Body text for content 1
</div>
</li>
As more content gets added the html will look like
<li class="row-2" style="display: block;">
<div class="content">
Example text for content 2
</div>
</li>
<li class="row3" style="display: block;">
<div class="content">
some more example text for content 3
</div>
</li>
etc
On my page load I have jquery being executed for the content which is already existing.
What I would like is jquery to be executed for each new content as it gets loaded on to the page.
Would I create the jquery individually for each item, then load the jquery when each item gets added to the page.
Or would I create a jquery function which detects when new content is added?
For now to begin with I would just like to alert when new content gets added so I can see how it is done?
Thank you for reading and any help provided.
Check answer to this SO question that could be a solution to bind the event on successful ajax load.
This might be the way you want to go for your website.
So what you can do is load the jquery with the elements itself and bind events to these elements.
I have been trying to use jquery tabs to launch html pages(within the same page) but somehow failing at it repeatedly. Seems like a simple enough thing, but in all my attempts either the tabs stop working or the page doesn't open.
Here's what I am trying to achieve - my index.html page with multiple tabs(say a,b,c). i have the individual pages a.html, b.html and c.html written and want them to be opened in the same page(below the tabs) such that the tabs are omnipresent. What would be the easiest way to get this working? I have tried simply calling the html pages or even using iframes, but nothing seems to work. Also, when I tried using iframes, the frame wasn't using the full height of the page available to it, but only say 20% of it(in latest firefox).
I know this is probably too trivial a question and might have been caused by some silly mistake at my end, but I have literally spent more than a week in trying to get this to work and am,now, at my wit's end!
Any help would be much appreciated!
Thanks
{ edited the post to add relevant code snippets}
<body>
...
<div id="navigation" class="menu">
<ul class="tabNavigation">
<li>A</li>
<li>B</li>
<li>C</li>
</ul>
</div>
<div>
<!--tab contents -->
<div class="panes">
<div id="A">A Content<p> tab A content</p>
<iframe src="a.html"></iframe></div>
<div id="B">B Content <p> tab B content</p>
<iframe src="b.html"></iframe></div>
<div id="C">C Content<p> tab C content</p>
<iframe src="c.html"></iframe></div>
</div>
</div>
<!-- JS to activate the tabs -->
<script>
$(function()
{
var tabContainers = $('div.tabs > div');
$('div.tabNavigation ul.tabs a').click(function()
{
tabContainers.hide();
tabContainers.filter(this.hash).show();
$('div.tabs ul.tabNavigation a').removeClass('selected');
$(this).addClass('selected');
return false;
}).filter(':first').click();
});
</script>
</body>
{Edited with specific code}
You could simply put the tabs on every page. The pages will reload but the tabs will be in the same place.
If the reload bothers you you're going to have to call the content of the html pages using javascript.
This script will call the html out of the pages and put the html into the panes of the divs with corresponding letters. This should serve what you are trying to achieve with iframes but without the iframes of course.
<script type="text/javascript">
$(document).ready(function() {
$.get("a.html", function(data){
$(#A).append(data);
});
$.get("b.html", function(data){
$(#B).append(data);
});
$.get("c.html", function(data){
$(#C).append(data);
});
});
</script>