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

Already on GitHub? Sign in to your account

Can't load alongside jquery upload #735

Closed
nveid opened this Issue Sep 30, 2012 · 5 comments

Comments

Projects
None yet
3 participants

nveid commented Sep 30, 2012

I've deduced my problems to the jquery file-upload not being able to work to the Aloha Editor.. (https://github.com/blueimp/jQuery-File-Upload)

I'm having issues where after an ajax call is made it can't see the plugin function it adds onto jquery (i.e. .fileupload). So after a $.getJSON() or a $.ajax call is made, when it comes back to the .success method jquery find $(selector).fileupload() my browser complains that it is undefined.

So I'm here to ask if perhaps I'm loading up Aloha editor wrong since its advertised to work correctly with jquery-ui.

Here's my code:

     <script src="/bundles/silvonaaloha/js/require.js"></script>
     <script src="/bundles/silvonaaloha/js/aloha-bare.js"
            data-aloha plugins="common/ui,common/image,common/format,common/block,common/table,common/paste,common/horizontalruler,common/paste,common/undo,common/highlighteditables,common/link,common/list,common/dom-to-xhtml,extra/metaview,extra/sourceview,silvona/save"></script>
    <script>
        Aloha.ready( function() {
            // Aloha.jQuery('.editable').aloha();
            Aloha.bind('aloha-editable-deactivated', function(event, myeditable) {
                editable = myeditable.editable.obj[0];
                update_data ={ "blocks" : [{name :editable.id, content: editable.innerHTML}] };
                /* Build our post data */
                jQuery.ajax ({
                    url: "{{ path('aloha_ajax') }}",
                    type: "POST",
                    data: update_data,
                    success: function(response){
                        console.log(response);
                        // Aloha.jQuery('.editable').mahalo();
                    }
                });
            });
            $('#aloha-devtool-source-viewer-content').live('keyup', function () {
                var text = $('#aloha-devtool-source-viewer-content').clone();
                var spanToKill = text.find('span.aloha-devtool-source-viewer-marker');
                spanToKill.remove();
                text = text.text();
                var selectededit = $('.aloha-editable-active');
                selectededit.html(text);
            });
        });
     </script>
Contributor

deliminator commented Sep 30, 2012

Don't share the host page's jQuery with Aloha. Load a separate jQuery just for aloha's use:

https://raw.github.com/alohaeditor/Aloha-Editor/hotfix/doc/guides/source/dependencies.textile

<!-- the jQuery used by your project -->
<script src="your-project/jquery-1.7.js"></script>
<!-- the jQuery used by aloha -->
<script src="aloha/src/lib/vendor/jquery-1.7.2.js"></script>
<script>
Aloha = window.Aloha || {};
Aloha.settings = Aloha.settings || {};
// Restore the global $ and jQuery variables of your project's jQuery
Aloha.settings.jQuery = window.jQuery.noConflict(true);
</script>
<script src="aloha/src/lib/require.js"></script>
<script src="aloha/src/lib/aloha.js"></script>

The above should always work for any project without causing any
problems.

nveid commented Sep 30, 2012

Thanks.. I've been attempting to do a custom build to get around this project... I'm trying to use the full build file it created and I get this javascript error problem:

ecma5shims.js GET http://localredneck/bundles/silvonaaloha/lib/aloha/ecma5shims.js 404 (Not Found)
aloha

Current code I'm using for my initialization is..

      <script src="/bundles/silvonaaloha/lib/aloha-full.js"
            data-aloha-plugins="common/ui,common/image,common/format,common/block,common/table,common/paste,common/horizontalruler,common/paste,common/undo,common/highlighteditables,common/link,common/list,common/dom-to-xhtml,extra/metaview,extra/sourceview,silvona/save"></script>
    <script>
        Aloha.ready( function() {
            // Aloha.jQuery('.editable').aloha();
            Aloha.bind('aloha-editable-deactivated', function(event, myeditable) {
                editable = myeditable.editable.obj[0];
                update_data ={ "blocks" : [{name :editable.id, content: editable.innerHTML}] };
                /* Build our post data */
                jQuery.ajax ({
                    url: "{{ path('aloha_ajax') }}",
                    type: "POST",
                    data: update_data,
                    success: function(response){
                        console.log(response);
                        // Aloha.jQuery('.editable').mahalo();
                    }
                });
            });
            $('#aloha-devtool-source-viewer-content').live('keyup', function () {
                var text = $('#aloha-devtool-source-viewer-content').clone();
                var spanToKill = text.find('span.aloha-devtool-source-viewer-marker');
                spanToKill.remove();
                text = text.text();
                var selectededit = $('.aloha-editable-active');
                selectededit.html(text);
            });
        });
    </script>

Just a note.. ecma5shims.js is NOT copied to the build directory.... I'm assuming thats for a reason and something wrong is being done with the build process... Though figured someone might be able to easily point to me what that is.

nveid commented Sep 30, 2012

One more note on the matter... I checked the build-full.js file that was generated.. It seems ecma5shims.js IS compiled inside the file... Any hep on this matter would be greatly appreciated why its still looking for ecm5ashims.js

Contributor

deliminator commented Sep 30, 2012

I would suggest you remove the extra/sourceview plugin. It requires ecma5shims with a relative path "../../lib/aloha/ecma5shims" instead of "aloha/ecma5shims". That's probably what is causing the problem.

nveid commented Sep 30, 2012

thats it.. I fixed the path.. doesn't look like its breaking anything else, but i put in a pull request for it.

@evo42 evo42 closed this Oct 17, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment