Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Feb 02 10:49
    laurenskling opened #5012
  • Dec 28 2022 23:34
    mexdevelop closed #5004
  • Dec 19 2022 12:07
    hermesalvesbr commented #4977
  • Nov 23 2022 01:47
    trentmillar closed #5011
  • Nov 23 2022 01:45
    trentmillar opened #5011
  • Nov 20 2022 15:13
    Enzaik commented #3994
  • Nov 20 2022 15:13
    Enzaik commented #3994
  • Sep 13 2022 13:31
    brooksbecton commented #59
  • Aug 30 2022 10:36
    VoronV48 commented #1069
  • Aug 30 2022 10:35
    VoronV48 commented #1069
  • Aug 30 2022 10:35
    VoronV48 commented #1069
  • Aug 24 2022 03:37
    VoronV48 commented #5001
  • Aug 17 2022 11:00
    emollett closed #5010
  • Aug 17 2022 11:00
    emollett opened #5010
  • Aug 17 2022 10:31
    emollett closed #5009
  • Aug 17 2022 10:31
    emollett opened #5009
  • Jul 27 2022 18:26
    taswarabbassss commented #3994
  • Jul 20 2022 18:58
    jamiebuilds closed #4136
  • Jun 17 2022 05:20
    jossmac unassigned #3262
  • Jun 14 2022 20:06
    jupazave closed #4555
tsuNammi
@tsuNammi
or do I have to hard code in every template view
nvm, google basically said no
tsuNammi
@tsuNammi
anyway to add a little explanation to the fields in the admin UI ?
tsuNammi
@tsuNammi
Mongoose model 'error' event fired on 'Post' with error:
next is not a function TypeError: next is not a function
why
tsuNammi
@tsuNammi
so I have <title><%= data.post.title %></title> in my header-partial for everything. if u visit /post/something_that_doesn't_exist
I get an error : Cannot read property 'title' of null
bc data.post doesn't exist obviously
Max Ma
@max8hine_twitter
I've been encountered with the error handler with flash-message view render issue. the error object from getUpdateHandler(req).process({fileds: validator}) is quite different than the error message from req.flash('error', msg) and gives the views a different object to render. using conditional statement could solve it , any solution from your guys? or Did I do it in the wrong way?
// Error from getUpdatehandler
{ info: [],
  success: [],
  warning: [],
  error:
   [ { type: 'ValidationError',
       title: 'There was a problem saving your changes',
       list: [Array] },
     'Password must be longer than 8 characters.' ] }
// Error from req.flash
{ info: [],
  success: [],
  warning: [],
  error: ['Password must be longer than 8 characters.' ] }
Max Ma
@max8hine_twitter
@tsuNammi you can get locals.section = 'info' in view directly , no need to use jQuery. the key of section is available in the view.
explanation in UI, you could useLists > Options > labelapi and next should nothing to do with Mongoose, it is express middleware function. hope it could help you.
tsuNammi
@tsuNammi
UI was good, I just used notes for each field, kinda hard to find anything about it in the documentation though
hmm, oh so you mean I can get the title of each post in the route file
and set it instead of in the actual render file
that's not stupid
I'll try
tried
view.render('post', {title: locals.data.post.title});
didn't work dude
TypeError: Cannot read property 'title' of undefined
tsuNammi
@tsuNammi
trying to do:
// Load the current post
view.on('init', function (next) {

    var q = keystone.list('Post').model.findOne({
        state: 'published',
        slug: locals.filters.post,
    });

    q.exec(function (err, result) {
        locals.data.post= result;
        console.log(result);
        title: locals.data.post.title;
        next(err);
    });

});
then
view.render('post');
but does not work
Max Ma
@max8hine_twitter
Hi, @tsuNammi, locals object is the object will pass down to your view. so if you want to load the title from view. you need make sure the key of 'title' nested the locals object directly.
view.on('init', function (next) {

    var q = keystone.list('Post').model.findOne({
        state: 'published',
        slug: locals.filters.post,
    });

    q.exec(function (err, result) {
        locals.data.post= result;
        /* Try this */
        locals.title: locals.data.post.title
        console.log("Locals: ", locals)
        console.log("Locals > Title: ", locals.title)
        next(err);
    });

});
Max Ma
@max8hine_twitter
Yes, keystoneJS need some helps for their documents. it is missing some of explanation for the APIs which is very important in build. Check out this site, http://keystonejs.netlify.com/guides, it did helped me somehow,
the above link explained why use view.on('init') over view.on('get') in indirect way. 🤔
tsuNammi
@tsuNammi
thanks man, but I guess I've already handled it with if/else statements in the headerpartial file. it's not nice and clean, but I figured if ppl went to a /post/id-that-does-not-exist, the only problem wouldn't just be the title
there's a lot of stuff in the post-template that would need to access a data.post which does not exist, and I can't handle them cleanly at the same time
doesn't matter anyways
I just send them to a 404/500 error default page instead handling all the errorenous database calls for an object that doesn't exist with if/else before actually making a default template with 'post not found'
unless anyone else has a better idea when ppl try to access a post/'slug' that does not exist
Arran Short
@sordfish
Hi All, is there a way to detect if data has come from an update in a model? basically I want to add a mongoose post hook that only triggers from admin ui saves and not updates.
Arran Short
@sordfish
woo @JedWatson is back
Max Ma
@max8hine_twitter
@sordfish have you tried the getUpdateHandler API from keystone? that API could help me to modify the data before update the model.
tsuNammi
@tsuNammi
so I tried deploying today
ran into a reaaaally weird problem
I have <strong> tags all over when I "inspect" using Chrome Inspector
they don't appear when I "view page source"
it's messing up my front end
I have no idea where to begin
it has something to do with the text that I've fetched from MongoDB
maaaybe because I have some a tags and strong tags entered into the content in the MongoDB
it appears normal when I access mongo shell and look at the objects
or it started when I started filling in stuff with a/strong tags in I think