# maxbuttons/7.1.3/assets/integrations/shortcake/edit-attribute-field-maxbutton.js

MaxButtons – Create buttons, version 7.1.3. 64 lines.

- Page: https://pluginprobe.com/plugins/maxbuttons/7.1.3/code/assets/integrations/shortcake/edit-attribute-field-maxbutton.js
- Raw: https://pluginprobe.com/plugins/maxbuttons/7.1.3/raw/assets/integrations/shortcake/edit-attribute-field-maxbutton.js
- Modified: 2018-04-27T05:47:18+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/maxbuttons/7.1.3/code/assets/integrations/shortcake/edit-attribute-field-maxbutton.js#L10-L20`.

```javascript
( function( $ ) {


	var sui = window.Shortcode_UI;
	//var construct = sui.utils.shortcodeViewConstructor;

	sui.views.editAttributeFieldMaxButton = sui.views.editAttributeField.extend( {

	updateButton: function(id)
	{
		this.setValue(id);
		var preview = this.$el.find('.button_preview');

		var query =  [{
				counter: 1,
				post_id: $( '#post_ID' ).val(),
				shortcode: this.shortcode.formatShortcode(),
			}];

		// provisional
		wp.ajax.post( 'bulk_do_shortcode', {
			queries: query,
			nonce: shortcodeUIData.nonces.preview,
		}).done( function( response ) {
			var button = response[1].response;
			preview.html(button);
		})

	},

	render: function ()
	{
		var self = this;
		var maxMedia = window.maxMedia;

		var data = jQuery.extend( {
			id: 'shortcode-ui-' + this.model.get( 'attr' ) + '-' + this.model.cid,
		}, this.model.toJSON() );

		maxMedia.setCallback( $.proxy(this.updateButton, this) );

		this.$el.html( this.template( data ) );
		this.triggerCallbacks();

		$(document).on('mb_media_buttons_open', function ()
		{
				$('.media-modal, .media-modal-backdrop').hide();

		});

		$(document).on('modal_close', function ()
		{
				$('.media-modal, .media-modal-backdrop').show();
		});

		this.updateButton( this.model.get( 'value' ) );

		return this;
	}

	}); // extend

} )( jQuery );

```
