Dynamically create jQuery Mobile page via JavaScript after clicking

前端 未结 5 1149
渐次进展
渐次进展 2021-01-30 05:39

My jQuery Mobile app consists of a single index.html page and contains only one page with a link on startup:

5条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-30 06:04

    I had some time to mess around with this and I've found a solution that works (tested).

    SOME NOTES:

    1. the javascript encapsulated in $(document).ready(); is for dynamically creating a page if the user navigates to your index.html file with a hash mark already appended (i.e. index.html#some_hash_mark).
    2. The function, create_page(page_id) is for creating a page from a link (or programatically if you like).
    3. Note that the jquery core script and the jquery mobile css are loaded before the $(document).ready() statement but that the jquery mobile script is loaded after.
    4. See that the body tag has been given an id that is refrenced when appending pages to it.

    Document Sample

    
    
    
    
    
    
    
    
    Fixed Headers Example
    
    
    
    
    
    
    Some #page_0 text...

    create new page

提交回复
热议问题