claritydigital Posted March 27, 2009 Share Posted March 27, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/151332-_get-updated_value-another-in-place-editorjquery-plugin-question/ Share on other sites More sharing options...
MadTechie Posted March 27, 2009 Share Posted March 27, 2009 Would need to see more code.. but as a guess i would say your running the update statement after a query to get the page data! Quote Link to comment https://forums.phpfreaks.com/topic/151332-_get-updated_value-another-in-place-editorjquery-plugin-question/#findComment-794866 Share on other sites More sharing options...
claritydigital Posted March 27, 2009 Author Share Posted March 27, 2009 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.. Quote Link to comment https://forums.phpfreaks.com/topic/151332-_get-updated_value-another-in-place-editorjquery-plugin-question/#findComment-794873 Share on other sites More sharing options...
MadTechie Posted March 27, 2009 Share Posted March 27, 2009 May need the whole thing.. Okay let me see if i have thing right.. you click to edit and change the text in the textbox, click out of the text box and the box goes blank ! Quote Link to comment https://forums.phpfreaks.com/topic/151332-_get-updated_value-another-in-place-editorjquery-plugin-question/#findComment-794876 Share on other sites More sharing options...
claritydigital Posted March 27, 2009 Author Share Posted March 27, 2009 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 Quote Link to comment https://forums.phpfreaks.com/topic/151332-_get-updated_value-another-in-place-editorjquery-plugin-question/#findComment-794880 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.