JavaScript Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsWeb DesignJavaScript Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old March 6th, 2013, 03:23 AM
paulh1983 paulh1983 is offline
Contributing User
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Dec 2004
Posts: 2,226 paulh1983 User rank is First Lieutenant (10000 - 20000 Reputation Level)paulh1983 User rank is First Lieutenant (10000 - 20000 Reputation Level)paulh1983 User rank is First Lieutenant (10000 - 20000 Reputation Level)paulh1983 User rank is First Lieutenant (10000 - 20000 Reputation Level)paulh1983 User rank is First Lieutenant (10000 - 20000 Reputation Level)paulh1983 User rank is First Lieutenant (10000 - 20000 Reputation Level)paulh1983 User rank is First Lieutenant (10000 - 20000 Reputation Level)paulh1983 User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 2 Weeks 1 Day 9 h 36 m 58 sec
Reputation Power: 201
jQuery - Jquery's mobile framework/phoneGap - dynamic content?

I am having trouble thinking of ways to serve dynamic content?

If you are familiar with these technologies, you will know that the pages have to be html and to use serverside you have to use jquery post data.

This all works for when i am logging user in. but how do i serve dynamic content so say i had a table in my database called orders,

once user logs in, I can show him all the orders list like this:

<a href="">Order 1</a>
<a href="">Order 2</a>

in a normal website the href would be something like: "orders.php?order_id=1234"

but I cant do that with Jquery/phonegap as they would probably open up a browser window (Not tested)

so i was thinking of doing something elaborate:

<a id="orderId" href="">Order 1</a>
<a id="orderId" href="">Order 2</a>

then using jquery detect which link they clicked on, get the ID attribute, and then i can:

1. send that to the server to get the relevant details
2. store it in the local storage, redirect user to another page orders.html and on page initialisation, use the local storage to get the data and do a post request..

Reply With Quote
  #2  
Old March 6th, 2013, 12:42 PM
E-Oreo's Avatar
E-Oreo E-Oreo is offline
Lost in code
Click here for more information.
 
Join Date: Dec 2004
Posts: 7,931 E-Oreo User rank is General 90th Grade (Above 100000 Reputation Level)E-Oreo User rank is General 90th Grade (Above 100000 Reputation Level)E-Oreo User rank is General 90th Grade (Above 100000 Reputation Level)E-Oreo User rank is General 90th Grade (Above 100000 Reputation Level)E-Oreo User rank is General 90th Grade (Above 100000 Reputation Level)E-Oreo User rank is General 90th Grade (Above 100000 Reputation Level)E-Oreo User rank is General 90th Grade (Above 100000 Reputation Level)E-Oreo User rank is General 90th Grade (Above 100000 Reputation Level)E-Oreo User rank is General 90th Grade (Above 100000 Reputation Level)E-Oreo User rank is General 90th Grade (Above 100000 Reputation Level)E-Oreo User rank is General 90th Grade (Above 100000 Reputation Level)E-Oreo User rank is General 90th Grade (Above 100000 Reputation Level)E-Oreo User rank is General 90th Grade (Above 100000 Reputation Level)E-Oreo User rank is General 90th Grade (Above 100000 Reputation Level)E-Oreo User rank is General 90th Grade (Above 100000 Reputation Level)E-Oreo User rank is General 90th Grade (Above 100000 Reputation Level)  Folding Points: 945 Folding Title: Novice Folder
Time spent in forums: 2 Months 7 h 43 m 47 sec
Reputation Power: 6991
You don't have to POST data, you can issue a GET request with jQuery too.

I don't know specifically how Phonegap will handle the href attribute in A links; it's worth trying though, as it might do exactly what you need without any additional effort on your part.

If it doesn't, then the approach you're considering is the correct one, but I would not use the "id" attribute to hold your order ID values. Instead, use a custom attribute for it:
Code:
<a orderid="5" class="order-link">Order 5</a>


Then you can bind an event handler to ".order-link" that will retrieve the appropriate data using the orderid attribute.

As a more generic approach, you could just use jQuery to bind to the click event on all <a> tags so that when clicked they request their href URL over an xmlhttprequest instead of invoking the native behavior of Phonegap. That way you don't have to write as many distinct event handlers.

I don't understand this logic at all:
Quote:
1. send that to the server to get the relevant details
2. store it in the local storage, redirect user to another page orders.html and on page initialisation, use the local storage to get the data and do a post request..


Why not just send them to orders.html first, show a loading icon initially, send the HTTP request to the server to get the order information, then hide the loading icon and update the page with the contents from the server.
__________________
PHP FAQ
How to program a basic, secure login system using PHP

Quote:
Originally Posted by Spad
Ah USB, the only rectangular connector where you have to make 3 attempts before you get it the right way around

Reply With Quote
  #3  
Old March 6th, 2013, 03:24 PM
paulh1983 paulh1983 is offline
Contributing User
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Dec 2004
Posts: 2,226 paulh1983 User rank is First Lieutenant (10000 - 20000 Reputation Level)paulh1983 User rank is First Lieutenant (10000 - 20000 Reputation Level)paulh1983 User rank is First Lieutenant (10000 - 20000 Reputation Level)paulh1983 User rank is First Lieutenant (10000 - 20000 Reputation Level)paulh1983 User rank is First Lieutenant (10000 - 20000 Reputation Level)paulh1983 User rank is First Lieutenant (10000 - 20000 Reputation Level)paulh1983 User rank is First Lieutenant (10000 - 20000 Reputation Level)paulh1983 User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 2 Weeks 1 Day 9 h 36 m 58 sec
Reputation Power: 201
thanks for replying.

post/get, you still need to send data to the server right. & to do that, need an id or am I missing something?

re your q:
these were two choices i was saying could happen.so for ex. if you clicked on order 1, i could either send order id to server through ajax & get the data OR store the id then take them to next page etc...

if i send them to orders.html first, how would I get the order id the selected?

Reply With Quote
Reply

Viewing: Dev Shed ForumsWeb DesignJavaScript Development > jQuery - Jquery's mobile framework/phoneGap - dynamic content?

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap