0

I have a page with multiple rows. I used a global view field to embed a view as a field. This embedded view has multiple editable fields (exposed forms).

When I display more than 30 rows the global view field will break my site. I decided to remove the global view field and to only load the block with the editable fields for a specific clicked row.

This works with the following jQuery code:

$(document).ready(function () {

$(".delivery-note-ref.clickable").click(function(){
var row = $(this).closest('.delivery-main');
var target_div = $(row).find('.ajax_content_edit_block');
var arg_div = $(target_div).attr("id"); 
$.ajax({
    url: Drupal.settings.basePath + 'views/ajax',
    type: 'POST',   
    data: {
        view_name: 'content_edit', //view name
        view_display_id: 'block', //view display
        view_args: arg_div,   //view contextual filter
    },
    dataType: 'json',
    success: function(response) {
      var output = response[1].data;      
      $(target_div).html(output);
      Drupal.attachBehaviors();
    },
    error: function(target_div) {
        alert('An error occured!');
    }
}); 
});
});

The code loads the block with the form, but when submitting the form the input is not saved and it only reloads the page.


When looking to the devtools network tab I noticed that the ajax request (mysite/system/ajax) type xhr isn't showing up when I enter something in the input field (initiator jquery.min.js?v=1.10.2:6).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.