Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preview not working on outside admin (on frontend) #108

Closed
eriktelepovsky opened this issue Feb 23, 2018 · 9 comments
Closed

Preview not working on outside admin (on frontend) #108

eriktelepovsky opened this issue Feb 23, 2018 · 9 comments

Comments

@eriktelepovsky
Copy link

Hi.

I have successfully configured markdown field and it works fine in the admin:

image

I also use it in my custom form on frontend, but unfortunately, the preview does not work. I can see the requests in the "Network" tab in the Google Chrome Developer Tools and I see the response is correctly returned:

image

I debugged markdown.js file at line 477:

xhr.success = function (response) {
    console.log('success');
    console.log(response);
    properties.preview.innerHTML = response;
    properties.editor = updateHeight(properties.editor);
    utils_1.triggerCustomEvent('markdownx.update', properties.parent, [response]);
};

and the result is, that "response" variable is always null:

image

Any idea what can cause the issue?

pip:

Django==2.0.2
django-markdownx==2.0.22
@xenatisch
Copy link
Collaborator

You debugged an intertwined, compiled JavaScript file. The Request class is fine - I wrote it 2 or 3 years ago, and I have since used it in many, many projects. If there is a problem, it's not there; at least not in that method.

@eriktelepovsky
Copy link
Author

Any idea where should I look elsewhere? The interesting fact is, the preview works in the Django admin but not on the frontend. But I can see the requests are being fired and the HTTP responses have correct content.

@xenatisch
Copy link
Collaborator

xenatisch commented Feb 24, 2018

You have edited the wrong file. That file will be overwritten the moment someone recompiles the TypeScript file, which is the source code for the part of the API that is written in JavaScript .

That said, I am still unclear what your problem is. Give me a proper outline in the following order:

  • What are you trying to do?
  • What is the problem?
  • What have you tried so far?
  • Where have you received the instructions from?

@xenatisch
Copy link
Collaborator

Here is the Request class, and here is the part you edited. It does nothing, until it is assigned to something.

What you need to do is to find out where the potential problem lies in markdownx.ts file.

@eriktelepovsky
Copy link
Author

Yes, I understand it will be overwritten, I just wanted to point to the issue. I think it will be easier to demonstrate using screen recording. Please look into my video I just uploaded:

https://youtu.be/UEs6Hurr9BM

Btw. I haven't edited the part you pointed to, I edited the compiled output of this part:

https://github.com/neutronX/django-markdownx/blob/master/static-src/markdownx/js/markdownx.ts#L703

I can't figure out why the original code doesn't work by default in my project.

Thank you.

@xenatisch
Copy link
Collaborator

The question is, why is it working in one place, but not the other!
Any terminal outputs?

@eriktelepovsky
Copy link
Author

eriktelepovsky commented Feb 25, 2018

Nothing suspicious in output :/ My guess is a conflict with some other JavaScript library I use in my project on the frontend, because your testapp works fine for me. I'll investigate it.

@adi-
Copy link
Member

adi- commented Apr 18, 2018

Any updates?

@adi-
Copy link
Member

adi- commented Nov 2, 2018

No additional info... closing.

@adi- adi- closed this as completed Nov 2, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants