saving array fails
-
Hi again,
I’d like to create some type of slider-widget. I know, there are plenty out there, but it seems none of them really is that convenient to use.
So I wanted to do create my own with the option of repeatable fields and a media uploader.
After some time working I’ve come so one media uploader button and a multiple select field catching the images.<select multiple="multiple" name="<?php echo $this->get_field_name( 'sosuImages' ); ?>[]" id="<?php echo $this->get_field_id( 'sosuImages' ); ?>" style="width:100%;"></select>
Saving goes like this:
$instance['sosuImages'] = array(); foreach ($new_instance['sosuImages'] as $img) { $instance['sosuImages'][] = $img; }
With jQuery I’ll get all option fields selected when the saving button is clicked, getting an array with all the option values.
Works gread using it in the theme widgets section, but breaks with ur plugin.
Do you have any ideas why?(this is the js btw)
jQuery(document).on('click', "#sosuNivoUpload", function (){ tb_show('', 'media-upload.php?type=image&TB_iframe=true'); $('#TB_window').css('z-index', 1005); widget_content = jQuery(this).parent(); window.send_to_editor = function(html) { imgurl = jQuery('img',html).attr('src'); imgalt = (jQuery('img',html).attr('alt') != '') ? jQuery('img',html).attr('alt') : jQuery('img',html).attr('src'); var current = $("textarea[id*='sosunivowidget']").val(); $("select[id*='sosunivowidget']").append($('<option></option>').val(imgurl).html(imgalt)); $("textarea[id*='sosunivowidget']").val(current + imgurl + "\n"); tb_remove(); return false; }; });
Cheers,
Michaelhttps://www.ads-software.com/extend/plugins/siteorigin-panels/
- The topic ‘saving array fails’ is closed to new replies.