Skip to content
This repository was archived by the owner on Oct 8, 2021. It is now read-only.

add json-support to $.mobile.changePage#799

Closed
markusweb wants to merge 3 commits intojquery-archive:masterfrom
markusweb:master
Closed

add json-support to $.mobile.changePage#799
markusweb wants to merge 3 commits intojquery-archive:masterfrom
markusweb:master

Conversation

@markusweb
Copy link

add support to retrieve json data and display the results as html with jquery.tmpl.js. it is controlled via url-parameter &mode=json, as this matches our application logic.

…splay the results with the help of jquery.tmpl.min.js.

to use this: the url must contain "mode=json" as get parameter. in the main/index.html the template has to be inserted.
the json data must contain a "template"-entry in the main section

{"id":"foobar", "template":"templateListIntro", "list":[ ... ]}
@markusweb
Copy link
Author

ony the commit to fa055bf... (jquery.mobile.navigation.js) is relevant in this pull. the change to the css is not needed. sorry, i am new to git

@dirceu-jr
Copy link

Hi there markusweb, it is a nice feature. But think using an external JSON API in your app, so if I can't modify the JSON how can I use this feature? Using the template outside the JSON maybe the very best option.

@markusweb
Copy link
Author

what do you mena by "external json api"? how would that help me? my server responds with json data rather then sending the complete rendered html. this will save some amount of data going over the air (in my case 30-50%). then in the jquery-mobile app the json data is rendered via jquery tmpl build and setup in the main index.html.
only drawback for a general use would be that at the moment i switch into the json mode by adding "&mode=json" in the url. thats ok, because this is how my server acts/responds. it maybe a good idea to have the json switch in kind of "data-mode='json'" in the a href in the html-page rather than using the get paramter in the url. but in a quick try i failed to find the right aproach.
so for me the "&mode=json" patch will work perfectly.

marku

@dirceu-jr
Copy link

Sorry for not begin clear, by "external json api" I mean when you can't change the server behaviour, like using a third party API. Thanks for the patch anyway. I'm using JQmobile with 3rd party JSON API but don't changed anything on the project, just load it when 'pageshow' == 'page i want'

@johnbender
Copy link
Contributor

A couple of notes here.

  • I don't think we want to build out functionality thats depends on an external plugin like this. If we were to provide something along these lines it would most likely be in the form of configuration and/or callbacks to allow users to choose how they do their templating.
  • It seems like using a data attribute on an anchor that transitions to a page being loaded with ajax would be preferable to the url get param.
  • You've got some whitespace issues, mostly indentation, with your commits though its not easy to tell exactly what they are. The project uses one tab per level of indentation.

Right now we're really focusing on device support and bug fixes as we move towards a beta. I'm going to close this request for now but when first release happens new features should be on the table and I invite you to resubmit then.

This pull request was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants