I use the standalone version of Responsive Filemanager 9 for image-selection on a < input> #image_link.
Where and how the responsive_filemanager_callback function should be used?
I'm trying to get it work as mentioned in the RFM documentation and the code below. This is needed to update the src attribute of the < img> #image_preview after selecting an image in RFM9.
This is my code:
<input id="image_link" name="link" type="text" value="">
<a class="btn iframe-btn" type="button" href="<?=FILEMANAGER_PATH;?>/dialog.php?type=1&field_id=image_link">Select</a>
<img id="image_preview" src="" />;
<script>
$('.iframe-btn').fancybox({
'width' : 900,
'height' : 600,
'type' : 'iframe',
'autoScale' : false
});
$('#image_link').on('change',function(){
alert('change triggered');
});
function responsive_filemanager_callback(field_id){
console.log(field_id);
var url=jQuery('#'+field_id).val();
alert('update '+field_id+" with "+url);
//your code
}
</script>
The $('#image_link')on.('change') function doesn't recognize the changes by RFM.
Thanks for your inputs!
I've found an other solution now that detects input changes by javascript.
It's maybe not very beautiful to check this by interval but simple, fast enough and reliable. Thanks to @kikito!
https://github.com/splendeo/jquery.observe_field
<input id="image_link" name="link" type="text" value="">
<a class="btn iframe-btn" type="button" href="<?=FILEMANAGER_PATH;?>/dialog.php?type=1&field_id=image_link">Select</a>
<img id="image_preview" src="" style="display:none;" />;
<script type="text/javascript" src="/jquery.observe_field.js"></script>
<script>
$('.iframe-btn').fancybox({
'width' : 900,
'height' : 600,
'type' : 'iframe',
'autoScale' : false
});
$(function() {
// Executes a callback detecting changes with a frequency of 1 second
$("#image_link").observe_field(1, function( ) {
// alert('Change observed! new value: ' + this.value );
$('#image_preview').attr('src',this.value).show();
});
});
</script>