I know this question have been asked here so many times, but i just cant show up Tinymce in my admin's flatpages. I don't know where I'm missing or doing something wrong. Please help me out where I'm going wrong.
The javascript file is in:
C:\Users\Kakar\web\cms\static\js\tinymce\tinymce.min.js
urls.py:
(r'^tiny_mce/(?P<path>.*)$', 'django.views.static.serve', { 'document_root': 'C:/Users/Kakar/web/cms/static/js/tinymce' }),
In my templates dir i have another admin folder, which have the change_form.html:
and right after {{ media }}:
<script type="text/javascript" src="/tinymce.min.js"></script>
<script type="text/javascript">
tinyMCE.init({
mode: "textareas",
theme: "simple"
});
</script>
In the firebug it says:
ReferenceError: tinyMCE is not defined
tinyMCE.init({
Please help me out. Thank you.
Your url for you tinymce script is currently pointing to http://yoursite/tiny_mce/ because of this: (r'^tiny_mce/... but the script you have included would attempt to GET tinymce.min.js from http:/yoursite/tinymce.min.js because you have not included the /tiny_mce/tinymce.min.js in front of it. If your tinymce.min.js is in a subdirectory you would need to include the path to it as follows <script type="text/javascript" src="/tiny_mce/(pathtodirectory)/tinymce.min.js"></script>
Related
I'm trying to get Slick Nav working and I'm currently testing it unsuccessfully on an empty page online. Locally it works perfectly, but it just doesn't want to run online - even if its the identical code. I have put the files from the "dist" folder from the slick nav download into a folder called "SlickNav" on my main folder on my FTP-Server (just like I did it locally). My test page contains the following:
<link rel="stylesheet" href="SlickNav/slicknav.css" />
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script src="SlickNav/jquery.slicknav.min.js"></script>
// I already tried putting my URL before the link rel and the script src above but it didn't help
<script>
$(function(){
$('#menu').slicknav({
label: "MENU"
});
});
<ul id="menu">
<li><a class="scroll" href="#features">Features</a></li>
<li><a class="scroll" href="#usage">Usage Instructions</a></li>
<li><a class="scroll" href="#examples">Examples</a></li>
<li>View on Github</li>
</ul>
I'm trying this for over 3 hours now and I just don't see it anymore.. perhaps someone had similar problems or simply sees the (probably dumb) mistake, I would be eternally grateful..
Found the solution after inspecting the console: For the code
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
which I simply copy and pasted had to be changed to match the https of my site -> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
So I am using django-wysiwyg-redactor==0.4.9 and Django==1.9.
The issue described here.
I tried a trick in comments, but that didn't help.
Also in browser's console I run this code directly to needed textarea:
$('#id_outboundprogram_set-2-text').trigger('redactor:init');
But anyway there are no redactor on it.
Textarea element looks like this before and after running above code:
<textarea class=" redactor-box" cols="40" data-redactor-options="{"lang": "en", "fileUpload": "/en/redactor/upload/file/", "imageUpload": "/en/redactor/upload/image/", "plugins": ["table", "video"]} id="id_outboundprogram_set-2-text" name="outboundprogram_set-2-text" rows="10"></textarea>
Strange thing is that this code, that I found in jquery.redactor.init.js from package files is not working:
// Initialize Redactor on admin's dynamically-added inline
// formsets.
//
// Credit to the approach taken in django-selectable:
// https://github.com/mlavin/django-selectable
$(document).on('click', '.add-row', function () {
$(this).parents('.inline-related')
.find('tr.form-row:not(.empty-form)').last()
.find('textarea.redactor-box')
.trigger('redactor:init');
});
Any ideas?
UPD:
Well, I still don't know why it happpens, but I solved this problem by including redactor.js file from package files and adding a little changes to above script:
<script type="text/javascript" src="{% static 'js/admin/redactor.js' %}"></script>
var program_tab = $('#outboundprogram_set-group'); // this is just because I have several inlines
program_tab.children('.add-row').on('click', function(){
program_tab.children('.inline-related:not(.empty-form)')
.last()
.find('textarea.redactor-box')
.redactor();
});
UPD 2:
Using this soution there is no plugins and image/file handlers. So I researched a little and found this article.
But image and file handling already implemented in django-wysiwyg-redactor, so I need just to use RedactorUploadView(). Urls can be found in urls.py file from sources. So here is the code:
var program_tab = $('#outboundprogram_set-group');
program_tab.children('.add-row').on('click', function(){
program_tab.children('.inline-related:not(.empty-form)')
.last()
.find('textarea.redactor-box')
.redactor({
imageUpload: "{% url 'redactor_upload_image' 'tours/out/programs/img/' %}",
fileUpload: "{% url 'redactor_upload_file' 'tours/out/programs/files/' %}",
plugins: ['table', 'video', 'fullscreen', 'image']
});
});
I would like to load MathJax in my base template with:
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
tex2jax: {inlineMath: [['$','$'], ['\\(','\\)']]}
});
</script>
<script type="text/javascript"
src="{% static "js/MathJax/MathJax.js?config=TeX-AMS-MML_HTMLorMML" %}">
</script>
However in the rendered template the URL is returned as:
/static/js/MathJax/MathJax.js%3Fconfig%3DTeX-AMS-MML_HTMLorMML
and MathJax doesn't work.
If I hard-code the URL as src="/static/js/MathJax/MathJax.js?config=TeX-AMS-MML_HTMLorMML" it works. How can I prevent Django/Mezzanine from escaping the ? and = characters? Is there an alternative approach?
[The reason I want to use a local MathJax is for development when I'm away from an internet connection; I use a CDN in production.]
I would try moving the config parameter outside the static reference and see if that helps:
<script type="text/javascript"
src="{% static "js/MathJax/MathJax.js" %}?config=TeX-AMS-MML_HTMLorMML">
</script>
I don't know Django or Mezzanine, but if the static is what is encoding the URL characters, moving them outside might prevent that.
I'm creating content in my pages with some javascript. I'm creating my divs and adding scripts. So, content is pulled into page via javascript.
I'm also using django-tinymce package in my admin site. I'm typing and saving my HTML code via HTML button on tinymce. Everything works fine in template. But, when i want to edit that content, my divs are replaced with an empty div in Tinymce HTML view.
Here is my original html code:
<div site-widget="bulletin">
<bulletin-navigator></bulletin-navigator>
<bulletin-filter-container></bulletin-filter-container>
<bulletin-event-list-container></bulletin-event-list-container>
</div>
<script type="text/javascript" src="http://192.168.30.42:10000/assets/js/common.js"></script>
<script type="text/javascript" src="http://192.168.30.42:10000/assets/js/bulletin.js"></script>
After saving this html code, when i press HTML button on tinymce again i see the following html code:
<div> </div>
<script type="text/javascript" src="http://192.168.30.42:10000/assets/js/common.js"></script>
<script type="text/javascript" src="http://192.168.30.42:10000/assets/js/bulletin.js"></script>
my tincmce config is like this in settings.py file:
TINYMCE_DEFAULT_CONFIG = {
'plugins': "table,paste,searchreplace",
'theme': "advanced",
'cleanup_on_startup': True,
'custom_undo_redo_levels': 10,
'skin' : "o2k7",
'width' : "100%",
'height' : "600px",
'extended_valid_elements': 'div|bulletin-navigator|bulletin-filter-container|bulletin-event-list-container'
}
It looks like TinyMCE is kindly filtering out any tags it does not recognize. It is being overly helpful...
You may need to define 'custom_elements' in TinyMCE - http://www.tinymce.com/wiki.php/Configuration:custom_elements
Spend some time Here and configure it to fit your specific needs.
im trying to use the Tiny MCE editor in my FlatPages, but the Editor dont appear and the css of the add form in flatpage is broken.
im using in this way:
url.py
(r'^tiny_mce/(?P<path>.*)$','django.views.static.serve',{'document_root': 'e:/wamp/www/diligencia/src/tiny_mce/jscripts/tiny_mce/'}),
template:
template overriding : templates/admin/flatpages/flatpage/change_form.html
code in my template change_form.html
<script type="text/javascript" src="/tiny_mce/tiny_mce.js/"></script>
<script type="text/javascript">
tinyMCE.init({
mode: "textareas",
theme: "simple"
});
</script>
i want to know where is the problem :(
Thanks
Regards,
Asinox
Hopefully you 've worked this out by now but I think that it 's just a typo and you need to change:
'e:/wamp/www/diligencia/src/tiny_mce/jscripts/tiny_mce/'
to
'e:/wamp/www/diligencia/src/tinymce/jscripts/tiny_mce/'
The later is the path that is stored inside the tinyMCE archive.