wire/modules/Inputfield/InputfieldPage/InputfieldPage.js
/**
	 * Initialize an InputfieldPage dependent select from its input.findPagesSelector element
	 * 
	 * The $t argument is one of these: 
	 * <input type='hidden' class='findPagesSelector' data-formatname='' data-label='title' value='parent=page.field'>
	 *     
	 * @param $t 
	 * 
	 */
Initialize an InputfieldPage dependent select from its input.findPagesSelector element

The $t argument is one of these:


@param $t
Initialize an InputfieldPage dependent select from its input . findPagesSelector element The $t argument is one of these : @param $t
function initSelector($t) {
		var selector = $t.val();
		if(selector.indexOf('=page.') == -1) return;
		var labelFieldName = $t.attr('data-label');
		var formatName = $t.attr('data-formatname');
		var $repeaterItems = $t.parents('.InputfieldRepeaterItem');
		if(!labelFieldName.length) $labelFieldName = 'name';
		var $wrap = $t.parents(".InputfieldPage");
		var $select2 = $('select#' + $wrap.attr('id').replace(/^wrap_/, '')); 
		if($select2.length < 1) return;
		var parts = selector.match(/(=page.[_a-zA-Z0-9]+)/g);
		for(var n = 0; n < parts.length; n++) {
			var part = parts[n]; 
			var name = part.replace('=page.', '');
			var $select1 = $('#Inputfield_' + name); 
			if(!$select1.length && $repeaterItems.length) {
				$repeaterItems.each(function() {		
					if($select1.length) return;
					$select1 = $('#Inputfield_' + name + '_repeater' + $(this).attr('data-page'));
				});
			}
			if($select1.length < 1) continue;
			$select1.change(function() {
				selectChanged($select1, $select2, selector, formatName, labelFieldName, part, true)
			});
			if($select1.val() && !$select2.val() && $select2.children('option[value!=""]').length < 1) {
				setTimeout(function() {
					selectChanged($select1, $select2, selector, formatName, labelFieldName, part, false)
				}, 100);
			}
		}
	}
function initSelector ( $t ) { var selector = $t . val ( ) ; if ( selector . indexOf ( '=page.' ) == - 1 ) return ; var labelFieldName = $t . attr ( 'data-label' ) ; var formatName = $t . attr ( 'data-formatname' ) ; var $repeaterItems = $t . parents ( '.InputfieldRepeaterItem' ) ; if ( ! labelFieldName . length ) $labelFieldName = 'name' ; var $wrap = $t . parents ( ".InputfieldPage" ) ; var $select2 = $ ( 'select#' + $wrap . attr ( 'id' ) . replace ( / ^wrap_ / , '' ) ) ; if ( $select2 . length < 1 ) return ; var parts = selector . match ( / (=page.[_a-zA-Z0-9]+) / g ) ; for ( var n = 0 ; n < parts . length ; n ++ ) { var part = parts [ n ] ; var name = part . replace ( '=page.' , '' ) ; var $select1 = $ ( '#Inputfield_' + name ) ; if ( ! $select1 . length && $repeaterItems . length ) { $repeaterItems . each ( function ( ) { if ( $select1 . length ) return ; $select1 = $ ( '#Inputfield_' + name + '_repeater' + $ ( this ) . attr ( 'data-page' ) ) ; } ) ; } if ( $select1 . length < 1 ) continue ; $select1 . change ( function ( ) { selectChanged ( $select1 , $select2 , selector , formatName , labelFieldName , part , true ) } ) ; if ( $select1 . val ( ) && ! $select2 . val ( ) && $select2 . children ( 'option[value!=""]' ) . length < 1 ) { setTimeout ( function ( ) { selectChanged ( $select1 , $select2 , selector , formatName , labelFieldName , part , false ) } , 100 ) ; } } }
Initialize an InputfieldPage dependent select from its input.findPagesSelector element
Initialize an InputfieldPage dependent select from its input . findPagesSelector element
// if there is no "=page." present in the selector, then this can't be a dependent select // dependent select // page matching part of the selector // see if available in page editor // if not available in page editor, and we are in a repeater,  // see if available in any of the repeaters we are nested within // monitor changes to the dependency field // determine if select2 needs to be populated // no options in $select2 select but primary $select1 has something selected… // it’s possible there are just no selectable options, but it’s also possible that  // this is a new page or the selects are newly added, so let’s find out…