-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace markitup's inline JS to fix load order bug
See: zsiciarz/django-markitup#25 django-markitup renders inline JS in each widget that configures the widget. This JS requires jQuery and markitup.js to already be loaded, which isn't the case if we're loading JS in the foot of the page. So, override the template that generates that inline JS, with something that generates a hidden tag containing only config. Then come back at the end of the JS loading, and configure the widgets. I'll do a similar PR upstream and hope that we can pull this out, later.
- Loading branch information
Showing
5 changed files
with
24 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
'use strict' | ||
$('.django-markitup-config').each(function(index) { | ||
var element = $(this.getAttribute('data-element')); | ||
var preview_url = this.getAttribute('data-preview-url'); | ||
var auto_preview = this.getAttribute('data-auto-preview'); | ||
if (!element.hasClass("markItUpEditor")) { | ||
if (preview_url) { | ||
mySettings["previewParserPath"] = preview_url; | ||
} | ||
element.markItUp(mySettings); | ||
} | ||
if (auto_preview) { | ||
$('a[title="Preview"]').trigger('mouseup'); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<div class="django-markitup-config" style="display: none" | ||
data-element="#{{ textarea_id }}" | ||
data-preview-url="{{ preview_url }}" | ||
data-auto-preview="{{ AUTO_PREVIEW|yesno:"1,0" }}"></div> |