Jump to content

$_GET updated_value(?) - Another In-Place Editor(Jquery Plugin) question.


claritydigital

Recommended Posts

Hi all,

 

I am trying to implement this rather snazzy in-place editor available here:

 

tutorial:

http://www.davehauenstein.com/code/jquery-edit-in-place/

 

js file:

http://davehauenstein.com/code/scripts/jquery.inplace.min.js

 

Using php/mysql i am updating the values sent through the editor, which works perfectly.. the value is inserted into the database. but once it updates, the plugin shows the default text for an empty element... and the content in the element isnt updated until the page is refreshed manually. where am i going wrong? this is the code im using:

 

The element with in-place edit:

 

<div class="editme1"><?php

$content = $_GET['update_value'];//i added this to try and get the updated value but im not really sure, just a guess. i have also used $_POST in an attempt to catch it....but i feel stupid even saying that..lol

if(!empty($content)) { echo "$content"; } else { echo "$row[profilevalue_8]"; } ?></div>

 

The file (update.php) that updates the database:

 

<?php include('includes/config.php');

include('includes/functions.php');

$name = $_POST[update_value];

$update = mysql_query("UPDATE profilevalues SET profilevalue_8 = '".$name."' WHERE profilevalue_user_id = '".uid()."'") or die(mysql_error());

?>

 

I would be so greatful for any help.

Link to comment
Share on other sites

Hi, thanks for your answer..

Umm..more code? Do you mean the $row variable? This is refering to a query done on page load. Its a user profile page:

 

User profile page:

 

if(isset($_REQUEST['id'])) {

$user = $_REQUEST['id'];

$info = mysql_query("SELECT * FROM users WHERE user_username = '$user'");

$rows = mysql_fetch_array($info);

$owner = $rows['user_username'];

$ownerid = $rows['user_id'];

$profile = mysql_query("SELECT * FROM profilevalues WHERE profilevalue_user_id = '$ownerid'");

$row = mysql_fetch_array($profile);

 

otherwise, there is the entire page. but i dont think you will need that? the link to the js file contains the js for the in-place edit function, and everything else is posted underneath that.

 

Thanks again..

Link to comment
Share on other sites

Whoops, I missed something... Sorry:

 

<script type="text/javascript">

$(document).ready(function(){

$(".editme1").editInPlace({

url: "http://www.mysite.com/update.php",

params: "ajax=yes",

});

 

$(".editme2").editInPlace({

url: "http://www.davehauenstein.com/code/jquery-edit-in-place/example/",

params: "ajax=yes",

bg_over: "#cff",

field_type: "textarea",

textarea_rows: "15",

textarea_cols: "35",

saving_image: "images/ajax-loader.gif"

});

 

$(".editme3").editInPlace({

url: "http://www.davehauenstein.com/code/jquery-edit-in-place/example/",

params: "ajax=yes",

field_type: "select",

select_options: "Change me to this, No way:0"

});

 

$(".editme4").editInPlace({

url: "http://www.davehauenstein.com/code/jquery-edit-in-place/example/",

params: "ajax=yes",

callback: function(original_element, html){

$("#updateDiv1").html("Here ya go.");

$("#updateDiv2").html("Here ya go 2.");

return(html);

}

});

});

</script>

 

OK what is happening is,

 

1. I click the element to edit the text.

2. I clear the old text, and enter the new text.

3. I click outside of the element to initiate Ajax to save the new text.

3a. Ajax shows "Saving..", which is default text for updating element.

4. Element reloads, and instead of showing the new text inside of element, the element shows (Click here to edit text), which is the default text in the js file for an element that returns empty.

5. I refresh the page manually, and new text is loaded in element.

I hope that makes more sense.

 

Thanks again

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.