0

I am currently trying to implement the pre-built inline editor located here: https://github.com/wbotelhos/inplace

Unfortunately, the support documentation leaves a lot to desire and I have very little experience with Javascript, jQuery, or Ajax.

I have been able to successfully implement the HTML edits:

<td><div class="inplace" data-field-name="name" data-field-value="{{people['name']}}" data-url="/update/{{id}}">{{ people['name'] }}</a></td>

The Js:

<script type="text/javascript">
$('.inplace').inplace();
</script>

and have successfully grabbed, and printed the info sent from the Javascript.

@app.route('/update/<id>', methods=["POST", "PATCH"])
@login_required
def update(id):
    new_data = request.get_data(as_text=True)
    print(new_data)
    return "200"

The issue I am facing, is that the Js returns an Undefined value which is what the HTML updates to.

Ignore the return "200" - I have tired several different methods. Success = True, json values, etc and nothing seems to work.

I am sure I am missing something simple.

2
  • Where is your ajax code? Commented Jul 14, 2022 at 20:35
  • I assume inside of jQuery. Not sure to be honest! Although, it has to be there as I am getting a response on the Python side haha. Commented Jul 14, 2022 at 20:50

1 Answer 1

1

It looks like you need to print json with the field name that matches your field_name attribute which is name.

So you will need to print something like this. I don't use python, so you will need to follow actual python syntax. Where the word name is correct, but you will need to add the value that you want shown

print('{"name":"NEW FIELD VALUE"}')
Sign up to request clarification or add additional context in comments.

1 Comment

So this worked! return {"name": data) in Python for anyone else looking at this. The only challenge now is that the element doesn't update with the new value automatically.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.