Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

passing parameters in jquerymobile?

Posted on 2014-09-11
23
Medium Priority
?
142 Views
Last Modified: 2014-09-24
Hi,

while ($paraloop = $respuesta->fetch_array()){
      
echo '<li><a href="#carg?feeder='.$paraloop['Feed'].'">'.$paraloop['Feed'].'</a></li>';


  } //Fin del while

the li have multiple references and i need to pass the parameter

How i can make this work in jquerymobile? works without the parameter in the address
0
Comment
Question by:joyacv2
  • 12
  • 11
23 Comments
 
LVL 83

Expert Comment

by:leakim971
ID: 40316851
You want to pass data to server side?
We use GET or POST
GET, the parameter is in the address that you don't want
POST, you POST a form, I don't see any to do tht with a link on page transition

A bad way would be to save the data in a cookie on click, not the click and the data-feed :
echo '<li><a class="feed" data-feed="'.$paraloop['Feed'].'" href="#carg">'.$paraloop['Feed'].'</a></li>';

Open in new window


and add this jQuery :
$(".feed").click(function() {
     $.cookie('feed', $(this).data("feed"));
});

Open in new window


read the cookie with PHP with :
$feed = $_COOKIE['feed'];
0
 
LVL 83

Expert Comment

by:leakim971
ID: 40316853
0
 
LVL 1

Author Comment

by:joyacv2
ID: 40316891
i want to use get in this case, don't require any security and can be changed in the address without problems, why cookie is a bad idea? is there other solution?
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Author Comment

by:joyacv2
ID: 40316907
when i press the link, then makes a reference to another page in the same html using the #page of jquerymobile when this load, it takes the parameter and sends to another php file with ajax and jquery and returns the info
0
 
LVL 83

Expert Comment

by:leakim971
ID: 40316962
I don't like the idea of using cookie to pass data.
if yu want to use get you sould let the parameters in the url, just like you did it
0
 
LVL 1

Author Comment

by:joyacv2
ID: 40316999
but don't work with jquerymobile, is there any other solution

<a href="#page2"> works

<a href="#page2?parameter="test"> don't work

any idea to solve that?
0
 
LVL 83

Expert Comment

by:leakim971
ID: 40317021
be craeful with the quotes, you have doube quotes inside double quotes
try this :

<a href='page2?parameter=test' onclick="return false;">
0
 
LVL 1

Author Comment

by:joyacv2
ID: 40317043
this doesn't work
0
 
LVL 1

Author Comment

by:joyacv2
ID: 40317055
<a href="#page2"> works

<a href="#page2?parameter=test"> don't work
0
 
LVL 83

Expert Comment

by:leakim971
ID: 40317057
remove the sharp
0
 
LVL 1

Author Comment

by:joyacv2
ID: 40317094
<a href="page2?parameter=test"> don't work

<a href="#page2parameter=test"> don't work
0
 
LVL 83

Expert Comment

by:leakim971
ID: 40317168
so for teh cookie way
0
 
LVL 1

Author Comment

by:joyacv2
ID: 40317258
the cookie way don't work, any other idea, i am frustrated with jquerymobile :(
0
 
LVL 1

Author Comment

by:joyacv2
ID: 40317265
I found this:

HTML:

 <a href="page1.htm?structure='123'">Structure</a>
JS:

$( document ).on( "pageinit", "#page1", function( event ) {
  var parameters = $(this).data("url").split("?")[1];
  parameter = parameters.replace("structure=","");
  alert(parameter);
});

in a concurrent site

can this work in my case for a while loop?
0
 
LVL 83

Expert Comment

by:leakim971
ID: 40317351
use a class, don't post link from concurrent site
0
 
LVL 83

Expert Comment

by:leakim971
ID: 40317360
forget my previous comment
0
 
LVL 1

Author Comment

by:joyacv2
ID: 40317500
do you need more info?
0
 
LVL 83

Expert Comment

by:leakim971
ID: 40317512
did you try it ?
remove the

try this :
$( document ).on( "pageinit",function( event ) {
0
 
LVL 1

Author Comment

by:joyacv2
ID: 40317621
the same problem, i found that any script is running until i press refresh!
0
 
LVL 83

Expert Comment

by:leakim971
ID: 40318469
Try this :
$(document).on("pagebeforeshow", "#index", function () {
     $(document).on("click", ".feedLink", function() {
          var to = $(this).attr("href")
          var options = { data : { feed : $(this).data("feed") } };
          $.mobile.changePage(to, options); // http://api.jquerymobile.com/jQuery.mobile.changePage/
     });
});

Open in new window


With :
echo '<li><a href="#carg" data-feed="' . $paraloop['Feed']  . '">' . $paraloop['Feed'] . '</a></li>';

Open in new window

0
 
LVL 1

Accepted Solution

by:
joyacv2 earned 0 total points
ID: 40319385
same problem, only things works after refresh the page!
0
 
LVL 83

Expert Comment

by:leakim971
ID: 40319391
I'm going to create test page and will come back
0
 
LVL 1

Author Closing Comment

by:joyacv2
ID: 40341114
perfect!
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction If you're like most people, you have occasionally made a typographical error when you're entering information into an online form.  And to your consternation, the browser remembers the error, and offers to autocomplete your future entr…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Suggested Courses

824 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question