Skip to content

Instantly share code, notes, and snippets.

@rileydutton
Created November 24, 2015 17:18
Show Gist options
  • Save rileydutton/d9d4ea12834ceb9bec63 to your computer and use it in GitHub Desktop.
Save rileydutton/d9d4ea12834ceb9bec63 to your computer and use it in GitHub Desktop.
<input name="attr_repeating_test_0_field" type="text" />
<fieldset class="repeating_inventory">
<table>
<tr border="1">
<td><input type="text" style="width:50px" name="attr_weight" value="0" title="item's weight" /></td>
</tr>
</table>
</fieldset>
<script type="text/worker">
console.log('=====> Testing setAttrs() with repeating fields by ID <=====');
on('change:repeating_inventory', function(){
console.log('===> Got change Event on repeating_inventory <===');
getSectionIDs('repeating_inventory',function(ids){
if(ids.length) {
var o={};
console.log('===> Attempting change on weight for id '+ids[0]+' <===');
o['repeating_inventory_'+ids[0]+'_weight']='taco';
setAttrs(o);
}
});
});
//on("change:repeating_inventory:weight", function() {
// setAttrs({
// repeating_inventory_weight: "howdy"
// });
//});
on("change:repeating_test:field", function() {
// setAttrs({
// repeating_test_0_field: "hellothar"
// });
var newrowid = generateRowID();
var newrowattrs = {};
newrowattrs["repeating_inventory_" + newrowid + "_weight"] = "testnewrow";
setAttrs(newrowattrs);
});
console.log(_.sortBy);
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment