logo
down
shadow

How to execute function based on URL in Iron Router without any data from collection?


How to execute function based on URL in Iron Router without any data from collection?

By : Chelsie Boudreaux
Date : November 22 2020, 09:00 AM
Hope this helps As MasterAM already said, just urlencode your url and provide it directly to your route, but as a query parameter, not a path component:
Template:
code :
Template.formButton.events({
  'submit #form': function (event, template) {
    event.preventDefault();
    var url = template.find('#input').value;
    if (url)
        Router.go('download?url=' + encodeURIComponent(url));
  }
});
this.route('download', {
  path: '/download',
  onBeforeAction: function() {
      var url = decodeURIComponent(this.params.query.url);
      console.log(url);
      Meteor.call(getUrl, url, function(error, result) {
        console.log(result)
        this.next();
      });
  }
});


Share : facebook icon twitter icon
Meteor Iron Router Run function when collection changes

Meteor Iron Router Run function when collection changes


By : Alexander Tihoniuk
Date : March 29 2020, 07:55 AM
wish helps you You can use the onData hook, provided that you're returning that data using the data helper. E.g this is what a route may look like
code :
this.route('routename',
    path : '/abc',
    waitOn: function () {
        return Meteor.subscribe('collection', this.params._id);
    },
    data: function() {
        return Collection.findOne({_id: this.params.id});
    }
    onData: function() {
         //Do something when the data found by the above changes
    }
});
Getting single data from collection in iron router

Getting single data from collection in iron router


By : Tas Tasniem
Date : March 29 2020, 07:55 AM
it helps some times There is nothing wrong with the code, like you say it work outsite the route this is happening because you are trying to load the data when the collection isnt ready, try with
code :
    waitOn:function(){
       return Meteor.subscribe('Example')
   }
   console.log(Imagess.find().fetch())
   output []// empty array
Using meteor's Collection FS in Iron Router / Iron Cli

Using meteor's Collection FS in Iron Router / Iron Cli


By : Prime
Date : March 29 2020, 07:55 AM
To fix the issue you can do Based on the generated structure, your first snippet will go into app/lib/collections and your second will go into app/server/collections.
Pulling data from collection using Iron router

Pulling data from collection using Iron router


By : Thanabhat
Date : March 29 2020, 07:55 AM
Does that help Your ManagementConfig template don't have access to tasks object. You can fix this by creating a helper method and passing the data.
code :
Template. ManagementConfig.helpers({
    'tasks': function(){
        //Change this to your task data
        return Lists.find({}, {sort: {name: 1}});
    }
});
iron-router wait on Collection.findOne() as data object before render

iron-router wait on Collection.findOne() as data object before render


By : Anton Headb
Date : March 29 2020, 07:55 AM
seems to work fine I'm not sure if I get your problem, but if I do, you should read about Controlling subscriptions, and especially Router.onBeforeAction('loading') . Now, you're reinventing the wheel.
shadow
Privacy Policy - Terms - Contact Us © animezone.co