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

Popular posts from this blog

1111. appearing after print sequence - php -

java - WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/board/] in DispatcherServlet with name 'appServlet' -

Ruby on Rails, ActiveRecord, Postgres, UTF-8 and ASCII-8BIT encodings -