samedi 4 août 2018

Redirect Issue on refresh

I just started working with EmberJS again and encountered something that is giving me a few issues. I have a an index route and a show route defined like this.

this.route('sample-units', function() {
  this.route('show', {path: '/:id'});
});

I'm able to to load the index route with this url, http://localhost:4200/sample-units and am able to go to the show route using


  


Which gives a url like so http://localhost:4200/sample-units/1344

The issue I'm experiencing is that any time I modify show.hbs, or refresh the page, Ember reloads and redirects me back to my index route instead of staying on the show page. I've worked with ember before and never had this issue, but that was back in 2.11. Has anyone encountered this before? I would assume that it would stay on the current route when I refresh the page, but for some reason it keeps leaving the show page and reloading on the index page. My show route is pretty basic and defined like so.

import Route from '@ember/routing/route';

export default Route.extend({
  model(params) {
    return this.get('store').findRecord('sample-unit', params.id);
  }
});

Does anyone know why this might be happening? Any help would be greatly appreciated.




Ember: What is the accepted paradigm for saving data to the back-end?

I am new to Ember and am used to the MVC model of creating controllers to move data between the view and the server. With Ember, it appears that controllers are support but there is very little documentation on them on the Ember website. From what I can tell, there is an alternative method to save data through the route. Is there an accepted paradigm for how to save data from the front-end to the back-end in Ember?




vendredi 3 août 2018

Ember redirect old routes

I have an Ember app where I am renaming a few routes. I am concerned users may have the old routes bookmarked. Where is the best place to handle redirects from the old route to the new one?




jeudi 2 août 2018

Ember.js check if link object exists before executing

I was wondering how to check in ember.js that a link object exists before execution. It's mainly the ember component of this question that I'm confused on. I tried to combine ember.js and pure javascript and I'm not sure if looks right. I know types of this question has been asked a lot of times, but I couldn't find an ember example.

Here are some snippets:

.js file

  beforeModel() {
    const var url = this.get('#feedbackLink');
    if (typeof url === 'undefined') {
        analyticsStore.logMessage('OpinionLabFeedlinkUndefinedError', 'Opinionlab feedback link is undefined');
    }
}

.hbs file

<div class="feedback">
<a id="feedbackLink" target="_top" rel="nofollow" role="button" onclick="OpinionLab.O_LC();return false;"
    <strong>
        <span class="secondary">
            <span class="feedback">Submit your feedback!</span>
        </span>
    </strong>
</a>
</div>

Thank you in advance.




RangeError: Maximum call stack size exceeded when using ember-cli-mirage

I am having issue using ember-cli-mirage. My instance of mirage is configured to use the RESTSerializer and the EmbeddedRecordsMixin for relationships. I am able to get records with relationship without a problem, however when I save the parent record I get the following error coming from the ember-data code:

RangeError: Maximum call stack size exceeded

Weirdly enough, if I just removed the EmbeddedRecordsMixin everything works fine. Is there some restriction or special thing you need to do use the EmbeddedRecordsMixin with mirage




mercredi 1 août 2018

How to resolve ember cli problems when the issue appears to reside in a plugin from node_module?

I am running into this problem when running ember scripts

The plugin {"_parallelBabel":{"requireFile":"./node_modules/ember-cli-htmlbars-inline-precompile/lib/require-from-worker","buildUsing":"build","params":{"templateCompilerPath":"./bower_components/ember/ember-template-compiler","parallelConfig":[]}}} didn't export a Plugin instance

What is the problem ember-cli is running into here? What would be a good strategy for debugging these type of problems?




Need to create the search value as null for multiple search folders

I have multiple folders with corresponding items, in that having search option. If I clicked the checkbox on folder A in the search option, it will show their items (eg. consider it having 4 items) and If I click the another checkbox of folder B (eg. consider it having 4 items) along with the folder A, it will show totally 8 items of folder A and folder B. Now When I remove the folder A or folder B from the checkbox, it still showing the 8 items. But I need only the corresponding folder items selected.

Here are my code:

Checkbox: Core.component.Checkbox.extend({
    click: function () {
        console.log(this);
        var nav = this.get("controller").get('selectedNavigator');
        var ret = this._super.apply(this, arguments);
        Ember.run.schedule('sync', this, function () {
            Ember.run.schedule('render', this, function () {
                var states = this.get('parentView.itemStates');
                var values =  Object.keys(states).filter(function (key) {
                    return states[key];
                });

                if (values.length === 0) {
                    Core.Action('core:contentHome', {});
                } else {
                    this.set('parentView.model.values',values);
                    nav.publish();
                }

            });
        });
        return ret;
    }
})

Please provide me suggest on this. I'm using Ember 1.4.0. If you need any further file also ask in comment. I'll provide. I'm new to the ember. Your help will be appreciate. Thanks in advance