Skip to:
Content
Pages
Categories
Search
Top
Bottom

BP 1.2 : \"bp_filter_request is not defined\"


  • grosbouff
    Participant

    @grosbouff

    Hi, I have a problem here when loading a member page of my own component.

    It says : “bp_filter_request is not defined”.

    The (core) function bp_filter_request is called inside my custom ajax.js :

    jQuery(document).ready( function() {

    var j = jQuery;

    /*load initial content*/

    if ( j(‘div.classified3s’).length ) {

    bp_filter_request( j.cookie(‘bp-classified3s-type’), j.cookie(‘bp-classified3s-filter’), ‘classified3s’, ‘div.classified3s’, j.cookie(‘bp-classified3s-page’), j.cookie(‘bp-classified3s-search-terms’) );

    }

    and the ajax.js file is loaded with this function :

    function classified3s_add_js() {

    global $bp;

    if (bp_is_user_classified3s()) {

    wp_enqueue_script( ‘bp-classified3s-ajax’, get_stylesheet_directory_uri() . ‘/classified3s/_inc/js/ajax.js’, array(‘dtheme-ajax-js’) );

    }

    }

    add_action( ‘wp_print_scripts’, ‘classified3s_add_js’, 1 );

    So I guess it should be workins as the function bp_filter_request is inside the file enqueued as ‘dtheme-ajax-js’.

    Any idea ?

    Thanks a lot !

Viewing 9 replies - 1 through 9 (of 9 total)

  • Brajesh Singh
    Participant

    @sbrajesh

    this is a scope and closure issue.

    the function will not be avilable outside the closure it was defined.It has a local scope in global.js.

    your better option would be copy it and define in your file until Andy puts it in the global scope.


    Andy Peatling
    Keymaster

    @apeatling

    I’m off to bed but will look at this in the morning, can you open a ticket please?


    grosbouff
    Participant

    @grosbouff


    MrMaz
    Participant

    @mrmaz

    I just ran into this same problem myself and came to the same conclusion as Brajesh. I ended up duplicating the function, which bugs me, but I can’t think of a *simple* workaround.

    The really annoying part is that it only needs to be in the global scope for the initial page load. Everything else works fine.

    The only way I can think of would be to use jQuery to bind events (or data arrays) to a globally available element, and then have the core code execute the events or retrieve the data arrays to get the custom filter parameters, which it would then pass to bp_filter_request() in a loop in its own scope.


    MrMaz
    Participant

    @mrmaz

    I just posted a solution to this ticket if anybody would like to test it out.


    grosbouff
    Participant

    @grosbouff

    Could you post the link here ?


    MrMaz
    Participant

    @mrmaz

    I posted the patch to your ticket here: https://trac.buddypress.org/ticket/1628


    MrMaz
    Participant

    @mrmaz

    Has anyone come up with a better solution for this yet? I don’t want to start duplicating JS just to get it into scope.


    MrMaz
    Participant

    @mrmaz

    Andy just moved all of the request functions into the global scope! Wooooot! Take a look at the trunk.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘BP 1.2 : \"bp_filter_request is not defined\"’ is closed to new replies.
Skip to toolbar