Pergunta

Well I don't think I am using proper term but I will try to explain the same. We have a Array of data coming from server using Remoting. Now we are using JSViews to bing the same to editable form with a update button. Once this button is pressed the data needs to be sent back to server.

We were successfully able to bind data but when we are logging the data we are seeing an extra property 'jQuery19105520686232484877' in the Array and in every element.

{Name: "Cheese Production Facility", RecordTypeId: "012i0000000C1lHAAS", Id: "a01i00000057WQMAA2", Number_of_Sites__c: 0, jQuery19105520686232484877: Object}

Is there is a way we can remove "jQuery19105520686232484877" property from the initial array?

Template Used

<li data-role="fieldcontain">
    <label for="propertyName">Name:</label>
    <input type="text" name="propertyName" data-link="Name" id="propertyName" value="" data-clear-btn="true"/>
</li>
 <li data-role="fieldcontain">
     <label for="dist">Dist:</label>
     <input type="text" name="dist" id="dist" data-link="Total_Number_of_Acres__c" value="" data-clear-btn="true"/>
</li>

JS Code

var propInfoObject = {
   Name: "Cheese Production Facility",
   RecordTypeId: "012i0000000C1lHAAS",
   Id: "a01i00000057WQMAA2",
   Number_of_Sites__c: 0
};
$.templates("#editPropertyTemplate").link("#editPropertyContent",propInfoObject);
Foi útil?

Solução

That extra property is the jQuery expando property that gets added if you attach events to an array:

$([myArray]).on("myevent" ...)

JsViews attaches an arrayChange event handler - which is why you see the extra property.

However the jQuery property is an object with the special property toJSON: function() {}.

The fact that that function returns nothing tells JSON.stringify() to ignore the property - to skip it during serialization.

So if you use JSON.stringify to serialize the data and send it to the server, that property should not show up at all...

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top