Skip to content

Commit b3a028f

Browse files
authored
gpnf-add-child-entries-to-the-top.js: Migrated.
1 parent 56e6249 commit b3a028f

File tree

1 file changed

+3
-22
lines changed

1 file changed

+3
-22
lines changed
Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,5 @@
11
/**
2-
* Gravity Perks // Nested Forms // Subscribe to Child Entry Updates
3-
* https://gravitywiz.com/documentation/gravity-forms-nested-forms/
2+
* We're no longer using the experimental folder for experimental snippets. 🚧
3+
* You can now find the snippet here:
4+
* https://github.com/gravitywiz/snippet-library/blob/master/gp-nested-forms/gpnf-add-child-entries-to-the-top.js
45
*/
5-
// Get your Nested Forms JavaScript instance where "4" is the Nested Form field ID.
6-
var gpnf = window.GPNestedForms_GFFORMID_13;
7-
var entryCount = 0;
8-
var doingItLive = false;
9-
10-
gpnf.viewModel.entries.subscribe( function( entries ) {
11-
if ( ! doingItLive ) {
12-
entryCount = entries.length;
13-
}
14-
}, null, 'beforeChange' );
15-
16-
gpnf.viewModel.entries.subscribe( function( entries ) {
17-
// Check if an entry was added.
18-
if ( ! doingItLive && entries.length > entryCount ) {
19-
doingItLive = true;
20-
gpnf.viewModel.entries.splice( 0, 0, gpnf.viewModel.entries.pop() );
21-
entryCount = entries.length;
22-
doingItLive = false;
23-
}
24-
} );

0 commit comments

Comments
 (0)