Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

What is the best way to load dynamic page in a view? #76

Closed
gpetrov opened this issue Jun 10, 2014 · 4 comments
Closed

What is the best way to load dynamic page in a view? #76

gpetrov opened this issue Jun 10, 2014 · 4 comments
Labels

Comments

@gpetrov
Copy link

gpetrov commented Jun 10, 2014

Hi Vlad,

Compliments about your Framework7! It looks amazing!

Just one question about loading dynamic pages in a view.

We would like to load a page that is initially empty with loader, that kicks off an Ajax call to load its content. When content arrives the page should be emptied and the loader replaced with the real content. Preferably afterwards we would like also to implement a pull to refresh.

What will be the best way to do so? Currently if the page is initially empty and then content is loaded with loadContent it becomes another page .. so the back button returns to the loader page instead of replacing the current...

Thanks,
George

@nolimits4web
Copy link
Member

Thanks, George.
You should not do loadContent again, you just need to replace content manually. For example:

You have some page with loader:

<div class="page" data-page="page-with-preloader">
  <div class="page-content"> .. just preloader here ...</div>
</div>

When page is loaded you do custom Ajax request and just replace page content with new one:

$$(document).on('pageAfterAnimation', function(e){
  var page = e.detail.page;
  if (page.name == 'page-with-preloader') {
    //Make custom Ajax request
    $$.get('something', function (data) {
      //And replace page-content
      $$(page.container).find('.page-content').html(data)
    })
  }
})

So you don't need at all to load another page, do everything here

@nolimits4web
Copy link
Member

Closing as seems to be solved

@imaxwen
Copy link

imaxwen commented Dec 25, 2015

I think if the view.router had an API like replaceContent(with page name parameter) would be better.

for example:

var popupView = null;
var cachedUrl = '';
// pop-up tool
function loadPopupPage(pageUrl) {
    if( cachedUrl != pageUrl ) {
        $$.get(pageUrl,function(pageContent){
            $$('.popup-view').find('.page-content').html(pageContent);
        });
    }
    cachedUrl = pageUrl;
    myApp.popup('.popup-view');
}

I need to handle the cache myself, if the view.router provides replaceContent API. so that I can handle the cache via myApp 's cacheDuration option.

@lock
Copy link

lock bot commented Jun 25, 2018

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot added the outdated label Jun 25, 2018
@lock lock bot locked as resolved and limited conversation to collaborators Jun 25, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants