Dependent Firing Multiple Times

Dependent Firing Multiple Times

Restful Web ServicesRestful Web Services Posts: 202Questions: 49Answers: 2

Is there anyway to stop or control how a dependent field is fired when the editor form initially opens? For example, I have two dependent fields in my form:

{
    label : 'Type:*',
    name : 'system_order_line.itemable_type',
    type : 'select',
}, {
    label : 'Item:*',
    name : 'system_order_line.itemable_id',
    type : 'select',
}, {
    label : 'Start date:',
    name : 'system_order_line.start_date',
    type : 'select',
}

The start_date options are dependent on the itemable_id options which are dependent on the itemable_type options like so:

editor_system_order_line_a.dependent( 'system_order_line.itemable_type', '/modules/DataTables/php/lib/Dependents/option.order_line_order_line_type_ids.php' );
editor_system_order_line_a.dependent( 'system_order_line.itemable_id', '/modules/DataTables/php/lib/Dependents/option.order_line_item_start_dates.php' );

When the form first opens this results immediately in 5 xhr requests to the server, like so:

XHR option.order_line_order_line_type_ids.php
XHR option.order_line_order_line_type_ids.php
XHR option.order_line_item_start_dates.php
XHR option.order_line_item_start_dates.php
XHR option.order_line_item_start_dates.php

It just seems really excessive and on a slow connection, i.e. mobile, could be problematic?

Answers

  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin

    I would only have expected a single XHR per dependent() call there. If you can give me a link to the page I can take a look at it.

    Allan

  • khrmkhrm Posts: 13Questions: 4Answers: 0

    I have the same Problem while i edit 2000 Entries,
    the dependent-Funktion is being called 2000 Times.

    Instead, i only want to call it one time!

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    Yep, I saw your other thread, we'll reply on that one,

    Colin

Sign In or Register to comment.