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

context plugins not loaded when editing outbox items #77

Closed
tomaszn opened this issue Jan 18, 2017 · 1 comment
Closed

context plugins not loaded when editing outbox items #77

tomaszn opened this issue Jan 18, 2017 · 1 comment

Comments

@tomaszn
Copy link
Contributor

tomaszn commented Jan 18, 2017

I wrote a plugin and included it in app/js/myapp/main.js. It runs properly (the "run" method is executed) on item creation or editing. But it doesn't work when I edit an item from outbox that failed to be synced.

@sheppard
Copy link
Member

Yes, this is due to a quirk in how plugins are registered by wq/app.js. Plugins trigger based on registered URL patterns, but the url for items in the outbox is /outbox/1. It shouldn't be too hard to either change the URL for outbox items (to e.g. /mymodels/outbox-1) or put in an extra bit of code to make sure that the plugin runs. In the meantime you could try using the lower-level router API to get it working:

define(['wq/router', 'wq/outbox', './myplugin'],
function(router, outbox, myplugin) {

router.addRoute('outbox/<slug>', 's', function(match, ui, params, hash, evt, $page) {
    outbox.model.find(match[1]).then(function(outboxItem) {
        var routeInfo = {
            // compute from outboxItem
        };
        myplugin.run($page, routeInfo);
    });
});

});

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

No branches or pull requests

2 participants