2 Replies - 1834 Views - Last Post: 18 April 2013 - 04:02 PM

#1 DaveLister   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 18-April 13

JQuery url encoding approach breaks code

Posted 18 April 2013 - 03:29 PM

Hi -

I am trying to implement a confirmation dialog, which I have done and works fine until the page is loaded from another jquery page, then the event (code) is not executed.

If I load the page by entering the url in a browser manually, everything is fine. If I load it by clicking on another jQuery page, because of the way the url is formed - it stops the code from executing.

After clicking on a button, instead of getting..
"http://www.somedomain.com/somedir/patient_records.php"
You get..
"http://www.somedomain.com/somedir/home.php#patient_records.php"

On the target page, I have the following code..
$(document).ready(function(e) {

$(document).delegate('#delpatient' , 'click', function() {
  $(this).simpledialog({
    'mode' : 'bool',
    'prompt' : 'Delete Patient?',
    'useModal': true,
    'buttons' : {
      'Yes': {
        click: function () {
          $('#dialogoutput').text('OK');// set variable here to already set vairable (crated dynamically) then..
		  		//header($del_loc);
				window.location.href='http://www.somedomain.com/somedir/del.php?pid=$id';
        }
      },
      'No': {
        click: function () {
          $('#dialogoutput').text('Cancelled');
        },
        icon: "delete",
        theme: "c"
      }
    }
  })
})
});



This works fine when the url is entered manually in the browser, but not when being called from another jQuery button on another page. I gather this is something to do with the way the url is constructed (with hash values.)

I can get it to work by adding.. rel="external" to the calling link. The problem is that I loose all the nice animation and transition effects.

Can anyone suggest an alternate approach or a fix for this problem ?

Many thanks..

Is This A Good Question/Topic? 0
  • +

Replies To: JQuery url encoding approach breaks code

#2 andrewsw   User is offline

  • no more Mr Potato Head
  • member icon

Reputation: 6957
  • View blog
  • Posts: 28,696
  • Joined: 12-December 12

Re: JQuery url encoding approach breaks code

Posted 18 April 2013 - 03:53 PM

?pid=$id';

It looks like you are trying to embed a PHP variable into your script. If so, this should be:

?pid=<?php echo $id; ?>';

This post has been edited by andrewsw: 18 April 2013 - 03:54 PM

Was This Post Helpful? 0
  • +
  • -

#3 DaveLister   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 18-April 13

Re: JQuery url encoding approach breaks code

Posted 18 April 2013 - 04:02 PM

Hi -

thanks for the reply, however - changing the code as you described did not help. The original code did work. Just that nothing works when called from another jQuery control using the url default encoding technique . The only way I can get it to work is to embed the rel="external" to the calling control. But as I say, this has its drawbacks.

Thanks..
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1