jimmiw

jimmiw does not currently provide support for this item.

12 comments found.

Hey,

Didn’t really know that one existed.

Anyways, the component i’ve made looks a bit different. Else the functionality seems similar.

Interesting.

We have been looking at inline editing, specifically jeditable type stuff.

My question.

We have a form submitted to the database.

We need to allow editing changes to be made in future for or clients, whereby they can retrieve their form from database, and make edits inline and save, back to the database.

Is this dooable.

Can you rig up an example, that actually uses database saving and editing. Rather than just pre filled forms, and cookies.

Regards

Hey, Sure.. the example will be kinda crude though, else it would take up too much space.

Two files used, first one is the one with the editme component: index.php

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
  <title>EditMe demo</title>
  <script src="jquery-1.4.2.min.js" type="text/javascript"></script>
  <script src="jquery.editme.js" type="text/javascript"></script>
  <link href="editme.css" rel="stylesheet" type="text/css" />
</head>
<body>

&lt;?php /** 
 * I just created a database called editme_test on my localhost.
 *
 * The table I used was kinda simple... just test :)
 *
 * create table stories (
 *   id int primary key auto_increment,
 *   title varchar(255)
 * );
 *
 * since this is a REALLY simple example, insert some data so we have an ID etc
 * insert into stories(title) values('test title');
 */
// hooks up the database connection
mysql_connect("127.0.0.1","root","12345");
mysql_select_db("editme_test");

// fetches out the data
$query = mysql_query("select title, content from stories where id = 1");
// Takes the data into the row variable
$row = mysql_fetch_array($query);

?&gt;

<label for="title">Title</label><br />
<input name="title" value="&lt;?=$row['title'];?&gt;" type="text" /><br />

<script type="text/javascript">
$(document).ready(function() {
  $('input[name="title"]').editme({
    autosave: function(data) {
      $.post('save_data.php', {
          'id': '1',
          'data':data,
          'field':'title'
        }, function(response) {
          if(response == "") {
            // data was saved, call the "saved" function
            $('input[name="title"]').editme('saved');
          }
          else {
            // data was not saved, show an error 
            alert(response);
          }
        }
      );
    }
  });
});
</script>

</body>
</html>

And here is the file that receives the data: save_data.php

<?php // fetches the post data
$id = $_POST['id'];
$field = $_POST['field'];
$data = $_POST['data'];

// hooks up the database connection
mysql_connect("127.0.0.1","root","12345");
mysql_select_db("editme_test");

// constructs the sql we are to use.
$sql = "update stories set {$field} = '{$data}' where id = {$id}";
// executes the query
mysql_query($sql);

// if we have an error, show it!
if(mysql_error() != "") {
  echo mysql_error();
}
?>

Hope you can use it… still, just a tad crude.

Can I update content from database? If yes, can you provide an example? Thank you!

Hey,

See the example for SportTipWorld, should be something like that right ?

Hi

I was wondering if there was a way to tell which input is passing the data? I am looking to use this on a large form and would like to take advantage of the autosave feature. Long story short, I am looking to have editme look at all of the $(‘input’) items as a whole and not specifically have to write each form element out.

For example: - the method you denoted already looks to do a ajax post, but you are specifically denoting what the name of the post is in regards to the data ( ‘data’:data, )

My question is if there is something that knows which input is posting the autosave so that it can be used as a global on the form?

$(document).ready(function() { $(‘input’).editme({ autosave: function(data) { $.post(‘save_data.php’, { ‘id’: ‘1’,

SOME _EDITME_IDENTIFIER_OF_INPUT_PASSING_DATA:data,

}, function(response) {

Thanks!!

Hello,

Currently there is no way of knowing what item is being updated. I’ll make an updated version soon, that sends the item that was updated with the autosave function.

Hello jimmiw!

Your script is great, it does what it says and it is easy to install.

I have just two questions: Is it a way to make it work with textarea? Or are you planning to develop a textarea version in the future?

Thanks!

Hello Cadence96!

Currently i’m not thinking about extending the script to handle more html elements. But it’s a good idea that I might do a bit later.

Glad you like the script

- Jimmiw

Hi Great File!

But what about your update concerning the item detection to autosave different input text?

Thanks

Hello Mike,

I’m not sure I follow you, what update?

The one about the textarea as well or ?

do you support dropdown be for i purchase

Hello,

Currently only input fields are supported.

I think i’ll do an update to the script someday soon though, since textareas are also requested.

Hi Jimmin nice script, simple and efficient… Can you provide an example as you have done to update the database with both input AND textarea ? Many thanks, Vincent

Hi,

Do you have an example (with code) inserting and updating using MySql?

This code above still works?

thanks

The example @Australia still works.

I Made a few adjusts but it worked :) thanks!

How Does it become “only the administrator can edit”?

Don’t load the script…

As usually, simplicity makes it perfect

Great Work! Good Luck!!!

by
by
by
by
by
by