javascript - Append attributes to object from cropper plugin -
i have object cropper plugin image attributes.
var data = $img.cropper('getdata'); //object {x: 90, y: 60, width: 720, height: 480, rotate: 0…} now need append more 2 values:
image_identifier = $('.image_identifier').text(); type_identifier = $('.type_identifier').text(); i tried code:
data.push({'image_identifier':image_identifier, 'type_identifier':type_identifier}); but getting : uncaught typeerror: data.push not function
your container object not array, has no array methods. should extend object new properties, easiest way using $.extend:
$.extend(data, { image_identifier: image_identifier, type_identifier: type_identifier }); note don't have assign result anything; $.extend augments first param, target object.
Comments
Post a Comment