• Gamers

    @baris here is some of my code, all hooks are firing, all but the "filter:composer.check"

    (function(config, app, ajaxify, $, templates) {
        'use strict';
    
        
    
        $(document).ready(function() {
    
    	
            require(['hooks'], function (hooks) {
    
    
               //validation of composer data before submit
                hooks.on('filter:composer.check', function (payload) {
    
                    console.log('------------- HOOK NOT FIRED -------------')
    
                    
                });
    
                //on composer open load variables to tpl
                hooks.on('filter:composer.create', function (data) {
    
                    console.log('------------- HOOK FIRED -------------')
                    
                });
            });
    
            //fired after composer is loaded, and ready for javascript
            $(window).on('action:composer.loaded', function (ev, data) {
    
                console.log('------------- HOOK FIRED -------------')
                
            });
    
            // after composer submit
            $(window).on('action:composer.submit', function(ev, data) {
                
                console.log('------------- HOOK FIRED -------------')
                
            });
    
            //after composer edited, we re load the tags of the post detail page if needed
            $(window).on('action:posts.edited', function(ev, data) {
    
                console.log('------------- HOOK FIRED -------------')
                
            });
    
            //after composer posted new
            $(window).on('action:posts.loaded', function(ev, data) {
    
                console.log('------------- HOOK FIRED -------------')
    
            });
        
        });
    
    })(config, app, ajaxify, $, window.templates || null);
    
  • NodeBB Admin

    Did you try putting a console.log here to see if it's triggered?

  • Gamers

    @baris yes, and the console log is working there. So Its like the fire event is not reaching my function or something.

    I actually modified that composer file in that place, and added my code there and its working. But this is not a clean solution, I should be able to do the same with the hook.

  • NodeBB Admin

    @Sebastián-Cisneros said in Composer custom field validation:

    //validation of composer data before submit
            hooks.on('filter:composer.check', function (payload) {
    
                console.log('------------- HOOK NOT FIRED -------------')
    
                
            });
    

    Did you check if this code is executed? You should be able to look in the hooks module loaded property to see if your listener is added.

  • Gamers

    @baris said in Composer custom field validation:

    console.log('------------- HOOK NOT FIRED -------------')

    console.log('------------- HOOK NOT FIRED -------------')
    is not being logged

    how can I look into the hooks module properties?
    console log of the hooks var? when?

  • NodeBB Admin

    Like this

    console.log('adding hook listener');
    hooks.on('filter:composer.check', function (payload) {
                console.log('------------- HOOK NOT FIRED -------------')
    });
    console.log(hooks.loaded);
    

    See if those print the function you just added.

  • Gamers

    @baris said in Composer custom field validation:

    console.log(hooks.loaded);

    {
        "action:ajaxify.start": {},
        "action:ajaxify.end": {},
        "filter:composer.check": {},
        "filter:composer.create": {},
        "filter:notifications.load": {}
    }
    

    337a9fac-aca5-417e-b83a-8ae14540fa5c-image.png

  • Gamers

    @Sebastián-Cisneros

    this is how I have the current hook coded

    //validation of composer data before submit
                hooks.on('filter:composer.check', function (payload) {
    
                    console.log('filter:composer.check');
    
                    var selectedTags = [$(".composer #topic-list-select").val()];
    
                    console.log('selectedTags');
                    console.log(selectedTags);
    
                  
    
                    return payload;
                    
                });
    

    nothing is getting logged on the console after submitting the composer.

  • NodeBB Admin

    Maybe put a breakpoint here and check why your listener isn't triggered. I tried on this forum and it worked fine.

  • Gamers

    @baris Thanks for the help. I appreciate it.


Suggested Topics

| | |

© 2014 – 2022 NodeBB, Inc. — Made in Canada.