1

i modified views_load_more module and create a custom ajax command:

Drupal.ajax.prototype.commands.custom_views_ajax_command = function(ajax, response, status) {
    //append new content has been loaded to old (scroll auto load: slimScroll + waypoints)
};

and this's my behaviors:

Drupal.behaviors.cva_autoLoad = { 
    attach: function(context, settings) { 
        $.each(Drupal.settings.cva_autoLoad, function(i, st) { 
        //if scroll down to last row: $(views li.pager-next a).click(); 
    } 
}

everythings work fine, but i dont know how to trigger the next link click event if height of views is shortern than window.height()

when views is initial, if its height is shortern than scroll bound height, i want to trigger ajax load automatically

i tried this, but no luck

if(/*this height < window height*/)
    $(next_link).click();

even without condition, nothing happens

i call drupal_add_js in function render($input) (views_plugin_pager)

how to fix this? or does anyone have any better ways?

sorry about my urgly english

EDIT

maybe my question is so stupid. if yes, plz let me know.

i really need help

i found this when read ajax drupal core and views:

var setting = Drupal.settings.views.ajaxViews['views_dom_id:'+st.view_dom];
setting.page = 1;
$.ajax({
    url: Drupal.settings.views.ajax_path, 
    type:'POST', 
    data: setting,
    dataType: "json",
    success: function(response) { 
        console.log(response);
        /*call Drupal.ajax.commands here ( it should be custom_views_ajax_command above*/
    },
});

does anyone know how to call Drupal commands or some ways are more legal?

2

1 Answer 1

1

yeah. thank askibinski so much! in this post: XHR2 upload using Drupal 7's ajax framework

and this is my solution:

if($(viewDom).height() < height ) {
    var element_settings = {};
    element_settings.progress = { 'type': 'none' }; 
    element_settings.event = "click";
    element_settings.setClick = false; 
    element_settings.url = Drupal.settings.views.ajax_path;
    element_settings.selector = viewDom;
    var setting = Drupal.settings.views.ajaxViews['views_dom_id:'+st.view_dom];
    setting.page = setting.page || 0;
    ++setting.page;
    element_settings.submit = setting;
    new Drupal.ajax(null, $(viewDom), element_settings).eventResponse($(viewDom)); 
    return;
}

and my real question is: how create then trigger ajax action with D7 ajax API in js

thank everybody alot.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.