engineer9090909090909090 / jquery-datepicker

Automatically exported from code.google.com/p/jquery-datepicker
0 stars 0 forks source link

.dpSetSelected - Can it not trigger the dateSelected function? #206

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
I'm using the date picker to pass dates to a PHP script to make an
availability calendar. I can store the dates just fine, but when I go to
load the page and use dpSetSelected() to populate the calendar it seems to
trigger the dateSelected() function which I have modified to:

$("#info").load("test1.php?date="+encodeURIComponent(selectedDate)+"&land-id="+<
?=$_GET['eid'];?>);

and it ends up deleting the query out of the database. This doesn't happen
if I use "click", but then it doesn't pass the date. Is there any way
around this limitation?

Thanks!

Original issue reported on code.google.com by bfamre...@gmail.com on 13 May 2010 at 10:09

GoogleCodeExporter commented 8 years ago
Sorry, I meant to say it deletes the record out of the database. Let me know if 
I
need to attach any files, I'll be happy to.

Original comment by bfamre...@gmail.com on 13 May 2010 at 10:12

GoogleCodeExporter commented 8 years ago
A link to the page would probably help...

However, it sounds like instead of using dpSetSelected you could just 
pre-populate
your input with the value from PHP e.g.

<input type="text" class="date-picker" value="<?php echo $date_value; ?>" />

Also, I'm not sure what you mean when you say you modified the dateSelected 
function.
If you want to do something when a date is selected you shouldn't modify 
anything,
you should bind a listener for the dateSelected event.

Also, you shouldn't delete records from a database on a GET request anyway. 
Otherwise
you will find search engine spiders and the like accidentally deleting records 
for
you. All changes that modify data should be done with a POST request.

Original comment by kelvin.l...@gmail.com on 14 May 2010 at 7:28

GoogleCodeExporter commented 8 years ago
The header.php file is:
http://pastebin.com/gjNWVP7x

test1.php:
http://pastebin.com/78GUjggG

I'm not too worried about spiders/crawlers since it's in a password-protected 
admin
directory. Will the <input> method allow me to set select multiple dates?

Original comment by bfamre...@gmail.com on 14 May 2010 at 5:24

GoogleCodeExporter commented 8 years ago
You could try something like this:

http://pastebin.com/1sSkGspC

Trace from PHP out into a hidden field and then access this from JS... Do the
dpSetSelected before adding the listener for the dateSelected event so that it
doesn't fire any events.

Re. the spiders/ crawlers, it is still best practice not to update on a GET 
request.
You could revisit a page from your browsers history or a number of other 
things. It
is a simple thing to switch the page to POST and I would recommend it.

If you are still having trouble please ask your question on
http://www.stackoverflow.com/ and tag it jquery and datepicker. I will try to 
answer
there if somebody else doesn't first - this area is meant for reporting bugs 
with the
datepicker code itself, not for support on how to use it...

Original comment by kelvin.l...@gmail.com on 14 May 2010 at 6:20

GoogleCodeExporter commented 8 years ago
Thanks for your help. I knew this was a bug-tracker but the link from the 
website
directed me here, so I figured at least I could try to make a suggestion for a
"feature" while I was getting my questions answered ;)

Original comment by bfamre...@gmail.com on 14 May 2010 at 6:28