This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.
josh70520
Is there any way to trigger a data-request when an image is selected/changed in a mediafinder field or a text input changes text?
fields:
image:
label: 'Tile Image'
mode: image
span: auto
type: mediafinder
attributes:
data-request: onChangeValue
text:
label: 'Tile Text'
span: auto
type: text
attributes:
data-request: onChangeValue
bg_colour:
label: 'Tile Background Colour'
options:
none: Transparent
blue: Blue
green: Green
purple: Purple
red: Red
yellow: Yellow
showSearch: 0
span: auto
type: dropdown
attributes:
data-request: onChangeValue
controller:
public function onChangeValue()
{
\Log::info('bloop', post());
}
The above only fires when the select has changed value, not the text nor the image.
daftspunky
Hi Josh,
The data-request
attribute is a low level framework call and it works with the select element by chance. To make a binding like this, locate the id="" tag on the element you want and bind to the change event. You can place this JS code in your controller view file or in a JS asset file. For example,
$('#MediaFinder-formMediaFile-media_file').on('change', function() {
alert('Media Updated!');
});
I hope this helps!
1-3 of 3