Prev Home Next

10 Two containers data-linked to the same array

Script:

// Data-link people to the details container, using the personTmpl template
$.link.personTmpl( "#details", people );
$.link.personTmpl2( people, "#details2" );

// Observable array change: insert two new people at index 1
$( "#insertPerson" ).click( function() {
    $.observable( people ).insert(
         1,    // index 1
        [      // add two new people
            { firstName: "NewPerson" },
            { firstName: "NewPerson2" }
        ]);
});