{"action":"created","issue":{"url":"https://api.github.com/repos/iambrandontaylor/django-admin-sortable/issues/158","repository_url":"https://api.github.com/repos/iambrandontaylor/django-admin-sortable","labels_url":"https://api.github.com/repos/iambrandontaylor/django-admin-sortable/issues/158/labels{/name}","comments_url":"https://api.github.com/repos/iambrandontaylor/django-admin-sortable/issues/158/comments","events_url":"https://api.github.com/repos/iambrandontaylor/django-admin-sortable/issues/158/events","html_url":"https://github.com/iambrandontaylor/django-admin-sortable/issues/158","id":187143086,"number":158,"title":"TinyMCE editor compatibility for HTMLField() within SortableStackedInline items","user":{"login":"jowan","id":16796,"avatar_url":"https://avatars.githubusercontent.com/u/16796?v=3","gravatar_id":"","url":"https://api.github.com/users/jowan","html_url":"https://github.com/jowan","followers_url":"https://api.github.com/users/jowan/followers","following_url":"https://api.github.com/users/jowan/following{/other_user}","gists_url":"https://api.github.com/users/jowan/gists{/gist_id}","starred_url":"https://api.github.com/users/jowan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jowan/subscriptions","organizations_url":"https://api.github.com/users/jowan/orgs","repos_url":"https://api.github.com/users/jowan/repos","events_url":"https://api.github.com/users/jowan/events{/privacy}","received_events_url":"https://api.github.com/users/jowan/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-11-03T17:51:09Z","updated_at":"2016-11-03T18:05:05Z","closed_at":null,"body":"I am using HTMLField() for a few items with TinyMCE editor.\r\nIf I use these fields within a SortableStackedInline item, when I reorder them the editor breaks and you can not input any more.\r\n\r\nThis is just about jQuery sortable and TinyMCE really - not this module.\r\n\r\nThe solution was posted here : http://stackoverflow.com/questions/3919928/tinymce-instances-in-jquery-sortable\r\n\r\nJust thought it's worth mentioning as others may use richtext input in their inline models. \r\n\r\n"},"comment":{"url":"https://api.github.com/repos/iambrandontaylor/django-admin-sortable/issues/comments/258225593","html_url":"https://github.com/iambrandontaylor/django-admin-sortable/issues/158#issuecomment-258225593","issue_url":"https://api.github.com/repos/iambrandontaylor/django-admin-sortable/issues/158","id":258225593,"user":{"login":"jowan","id":16796,"avatar_url":"https://avatars.githubusercontent.com/u/16796?v=3","gravatar_id":"","url":"https://api.github.com/users/jowan","html_url":"https://github.com/jowan","followers_url":"https://api.github.com/users/jowan/followers","following_url":"https://api.github.com/users/jowan/following{/other_user}","gists_url":"https://api.github.com/users/jowan/gists{/gist_id}","starred_url":"https://api.github.com/users/jowan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jowan/subscriptions","organizations_url":"https://api.github.com/users/jowan/orgs","repos_url":"https://api.github.com/users/jowan/repos","events_url":"https://api.github.com/users/jowan/events{/privacy}","received_events_url":"https://api.github.com/users/jowan/received_events","type":"User","site_admin":false},"created_at":"2016-11-03T18:05:05Z","updated_at":"2016-11-03T18:05:05Z","body":"No problem, by no means urgent. Here is what I did in the JS.\r\nWorked for me but it's probably too situation specific to roll out.\r\n\r\n```\r\n(function($){\r\n\r\n    $(function() {\r\n        var sorting_urls = $(':hidden[name=\"admin_sorting_url\"]');\r\n        if (sorting_urls.length > 0)\r\n        {\r\n            var sortable_inline_groups = sorting_urls.closest('.inline-group')\r\n            var sortable_inline_rows = sortable_inline_groups.find('.inline-related');\r\n\r\n            sortable_inline_groups.addClass('sortable')\r\n            sortable_inline_rows.addClass('sortable');\r\n\r\n            sortable_inline_groups.sortable({\r\n                handle : 'h3',\r\n                axis : 'y',\r\n                containment : 'parent',\r\n                create: function(event, ui) {\r\n                    $('.inline-related :checkbox').unbind();\r\n                },\r\n                tolerance : 'pointer',\r\n                items : '.inline-related',\r\n                start: function (e, ui) {\r\n                    $(ui.item).find('textarea').each(function () {\r\n                        tinymce.execCommand('mceRemoveEditor', false, $(this).attr('id'));\r\n                    });\r\n                },\r\n                stop : function(event, ui)\r\n                {\r\n                    $(ui.item).find('textarea').each(function () {\r\n                        tinymce.execCommand('mceAddEditor', true, $(this).attr('id'));\r\n                    });\r\n                    if ($('.inline-deletelink').length > 0) {\r\n                        $(ui.sender).sortable('cancel');\r\n                        alert($('#localized_save_before_reorder_message').val());\r\n                        return false;\r\n                    }\r\n\r\n                    var indexes = [];\r\n                    ui.item.parent().children('.inline-related').each(function(i)\r\n                    {\r\n                        var index_value = $(this).find(':hidden[name$=\"-id\"]').val();\r\n                        if (index_value !== \"\" && index_value !== undefined) {\r\n                            indexes.push(index_value);\r\n                        }\r\n                    });\r\n\r\n                    $.ajax({\r\n                        url: ui.item.parent().find(':hidden[name=\"admin_sorting_url\"]').val(),\r\n                        type: 'POST',\r\n                        data: { indexes : indexes.join(',') },\r\n                        success: function() {\r\n                            var fieldsets = ui.item.find('fieldset'),\r\n                                highlightedSelector = fieldsets.filter('.collapsed').length === fieldsets.length ? 'h3' : '.form-row',\r\n                                icons = ui.item.parent().find('h3 > .fa');\r\n\r\n                            // set icons based on position\r\n                            icons.removeClass('fa-sort-desc fa-sort-asc fa-sort');\r\n                            icons.each(function(index, element) {\r\n                                var icon = $(element);\r\n                                if (index === 0) {\r\n                                    icon.addClass('fa fa-sort-desc');\r\n                                }\r\n                                else if (index == icons.length - 1) {\r\n                                    icon.addClass('fa fa-sort-asc');\r\n                                }\r\n                                else  {\r\n                                    icon.addClass('fa fa-sort');\r\n                                }\r\n                            });\r\n\r\n                            ui.item.find(highlightedSelector).effect('highlight', {}, 1000);\r\n                        }\r\n                    });\r\n                }\r\n            });\r\n        }\r\n    });\r\n\r\n})(django.jQuery);\r\n```\r\n\r\n> "}}
{"actor":{"display_login":"jowan"}}