Force sequence of methods to have your call in default value?

3

I have a framework that is basically used in the construction of forms and events HTML/jQuery with PHP , an example call:

$VIDB_input = new \vidbModel\inputElement(); 
$documentos_date_action = 'triggered';
$documentos_date_conv = \vidbModel\convertDates::exec_format_date($data[0]['documentos_date'], 'd/m/Y', 'Y-m-d');
$documentos_date = $VIDB_input->value($documentos_date_conv)->field('documentos_date')->mask('date_br_d_m_Y')->name('documentos_date')->type('text')->validator('date_br')->additional_classnames('documentos_date')->datepicker('')->comboAction(true, $documentos_date_action)->comboValue('S/M')->input(0);

This call above does the same thing as this (there are more events but they do not fit the example):

        $(document).on('focusin', '.input-field', function () {
            var $this = $(this);
            var mask = $this.data('input-mask');
            if (mask === 'undefined') {
                console.log('no-mask');
            } else {
                console.log('put-mask');
            }
        });
    

$(document).on('click', '.combo-action-trigger', function () {
    var $this = $(this);
    var $input = $this.closest('.input-group').find('.input-field');
    var previousValue = $input.val();
    var previousMask = $input.data('input-mask');
    if ($this.is(':checked')) {
        var comboValue = $this.val();
        $input.data('input-mask', 'undefined');
        $input.data('previous-value', previousValue);
        $input.data('previous-mask', previousMask);
        $input.val(comboValue).prop('readonly', true);
    } else {
        var previousValueI = $input.data('previous-value');
        var previousMaskI = $input.data('previous-mask');
        $input.data('input-mask', previousMaskI);
        $input.val(previousValueI).prop('readonly', false);
    }
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><scriptsrc="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>


<div class="input-group"><input type="text" name="documentos_date" data-input-mask="date_br_d_m_Y" data-input-field="documentos_date" data-input-validator="date_br" value="S/M"class="form-control input-field documentos_date " readonly="true" ><span class="input-group-addon">S/M<input type="checkbox" class="combo-action-trigger" value="S/M" checked="true" ></span></div>

The problem occurs in the following situation (For this example, it occurs in all situations when there is a need to repeat the call):

I instantiated an input as in the previous example, and then needed to start another input, but this new input, for example, would not receive any comboAction ( comboAction is the name given to actions within a% , as in the example, change the value of a field to a predefined value by dialing .input-group , and return to the previous value by deselecting the same checkbox ), thus it automatically pulls the value set in the previous call, in this case, it would start a second checkbox with input set value by setting comboAction if I do not set checkbox on this new call.

The false value for the default method is comboAction , I would like, somehow, when I started this second call, it did not retrieve the value saved in the instance, but the false value method, but this does not kill the instance, as I may need to render dozens of inputs in a default and it is not feasible to reinstall every time, and this should apply to all methods of the classes in question.

  • Is it possible to define (perhaps in a constructor?) that a class should call X methods and that if they are not previously called builder calls them as default?
  • If possible, how to do this?
  • If it is not possible, is there any other solution? Or should I redesign the classes that would depend on this solution to work properly?

NOTE: I've done a similar question, but the problem was with the order of the call, this problem has already been solved with the comment left, there is only this problem with residual value in the instance.

    
asked by anonymous 06.11.2017 / 16:29

0 answers