[fx.php_list] Re: [off] Jquery issue

  • From: Dale Bengston <dale.bengston@xxxxxxxxx>
  • To: fx.php_list@xxxxxxxxxxxxx
  • Date: Sat, 11 Feb 2017 15:27:07 -0500

Hi Bob,

Binding a click function can be an issue if the element doesn’t exist when the 
page loads. So, if your dates piece isn’t working, perhaps you can back the 
function out to work on anything in the page, regardless of when it loads. The 
syntax I use is

$(document).on(‘click', ‘.bookthis', function() {
 $('.content').load(‘dates.php');
 return false;
});

$(document).on(‘click', ‘.category', function() {
 $('.content').load(‘activity.php');
 return false;
});

Dale

On Feb 11, 2017, 2:48 PM -0500, Bob Patin <bob@xxxxxxxxx>, wrote:

OK, this seems so simple, but I’m stumped:

INDEX page contains all my JQuery; all of the subsequent pages load into a 
“content” DIV:

CATEGORY page loads; click button, which loads an ACTIVITY page;
click button, which loads a DATES page

Very simple stuff.

When the DATES page loads, a function needs to fire so that I can set up a 
date picker, but it doesn’t ever run.

To test, I put this code into the ACTIVITY page:

<script type="text/javascript">
$(document).ready(function(){
alert('test');
});
</script>

As you would expect, I get an alert when the ACTIVITY page loads.
Then, when the DATES page loads, I put in the exact same code, but it never 
runs.

Both pages are loaded using a simple line (here they are, with extraneous 
stuff omitted):

// ACTIVITY
$('.content').delegate('.category', 'click', function(){
$('.content').load(‘activity.php');
return false;
});
// BOOK THIS
$('.content').delegate('.bookthis', 'click', function(){
$('.content').load(‘dates.php');
return false;
});

SO, my question is this: why does my alert fire on the first event (ACTIVITY) 
but not the 2nd?
I even put a super-simple DATES.PHP page up, with one word on it, and then 
the alert code.

If someone can help me with this, I’d be really thankful; I’ve stared at it 
all morning and can’t see anything amiss.

Thanks,

Bob Patin
Longterm Solutions
bob@xxxxxxxxxxxxxxxxxxxxx
615-333-6858
FileMaker 9, 10, 11, 12 & 13 Certified Developer
http://www.longtermsolutions.com
-
iChat: bobpatin@xxxxxx
Twitter: bobpatin

FileMaker Consulting
FileMaker Hosting for all versions of FileMaker
PHP • Full email services • Free DNS hosting • Colocation • Consulting



Other related posts: