robster All American 3545 Posts user info edit post |
Ok,
Quick question for you jquery pros ...
I have the following ... trying to use jquery shortcuts within regular javascript ...
function showReviews(mid){ $('#detaildiv').html(jQuery.get('scripts/getreviews.php?mid='+ mid)); }
So ... just trying to fill a div after clicking on a row in a table ex: <tr onclick="showReviews(10)" >yadayada</tr>
I just get $ is not a function ... so I figure I have to tell it to look at jquery ... but I am just not that familiar with how you have to tie this all together and properly initialize this. 8/6/2010 12:31:11 AM |
lewisje All American 9196 Posts user info edit post |
you have to load jQuery somehow, like by putting it in a script tag before you use any of the shortcuts 8/6/2010 12:43:13 AM |
kiljadn All American 44690 Posts user info edit post |
http://docs.jquery.com/Using_jQuery_with_Other_Libraries 8/6/2010 9:02:26 AM |
robster All American 3545 Posts user info edit post |
Ok, so I got it all initialized, and the .get shortcut is grabbing the contents from the script, as I wanted it to do...
However, its not setting the contents of the "detaildiv" div ...
I can see the div, as I have placed it with set height and width and background color for positioning/layout purposes, but no contents are being written to it at all.
function showReviews(mid){ contents = jQuery.get('scripts/getreviews.php?mid='+ mid); jQuery('#detaildiv').html(contents); } 8/6/2010 10:06:09 AM |
FroshKiller All American 51913 Posts user info edit post |
You're fucking up trying to set the HTML content of #detaildiv to the return value of the $.get. Read the documentation. Use a callback function on the $.get that sets the HTML content of #detaildiv to the the data returned.
function showReviews(mid) { $.get('scripts/getreviews.php?mid=' + mid, function(data) { $('#detaildiv').html(data); }); }
[Edited on August 6, 2010 at 10:10 AM. Reason : ...]8/6/2010 10:09:19 AM |
robster All American 3545 Posts user info edit post |
ahh shit ... you're right ... thanks -
function showReviews(mid){ contents = jQuery.get('scripts/getreviews.php?mid='+ mid, function(data) { $('#detaildiv').html(data); }); }
[Edited on August 6, 2010 at 10:14 AM. Reason : .] 8/6/2010 10:10:40 AM |
FroshKiller All American 51913 Posts user info edit post |
No sweat. What are you working on? 8/6/2010 10:11:42 AM |
robster All American 3545 Posts user info edit post |
I built this Event data management system, which ties in to an iPhone app.
Its focused for State Fair organizations right now, and Indiana State Fair (which starts today) and NC State Fair are my first 2 clients.
They wanted to be able to see all the location listings and manage the reviews/ratings (filter out any that looked like trash or used profanity) ... so I created a table view on the left, and want to use this to populate the list of reviews on the right hand side when they click on an individual row in the table.
Then, from there, they can delete any abusive reviews.
[Edited on August 6, 2010 at 10:17 AM. Reason : .] 8/6/2010 10:17:39 AM |
FroshKiller All American 51913 Posts user info edit post |
This bit you posted when you edited:
function showReviews(mid){ contents = jQuery.get('scripts/getreviews.php?mid='+ mid, function(data) { $('#detaildiv').html(data); }); }
That's setting contents to the XMLHttpRequest object returned by $.get and not doing anything with it. Doesn't make much difference, I guess, but if you need to optimize, there it is.
When is showReviews called? Is it when the user clicks a link to request the reviews or what?8/6/2010 10:21:20 AM |
robster All American 3545 Posts user info edit post |
its called when the user clicks on the row of the table, each row using a different mid in the function.
Its working now with the above script ... html content is showing up in the div correctly. 8/6/2010 10:35:37 AM |