Skip to content

onClick event on array "+ add" button #208

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
dlodeprojuicer opened this issue Jan 12, 2015 · 7 comments
Open

onClick event on array "+ add" button #208

dlodeprojuicer opened this issue Jan 12, 2015 · 7 comments

Comments

@dlodeprojuicer
Copy link
Contributor

Is it possible to make onClick work on array buttons?

        {
          "key": "Questions",
          "add": "New Question",
          "onClick": "myFn()",
       }
$scope.myFn = function() {
   console.log('blah blah')
}
@davidlgj
Copy link
Contributor

I guess, but why? Whats the use case? It's a bit fiddly since it already has a ng-click that adds an instance to the array.

@dlodeprojuicer
Copy link
Contributor Author

I want to create a list that will be updated everytime "+add new" is clicked

@davidlgj
Copy link
Contributor

Updated in what way? From server? What about the instance being added?

Do a workaround otherwise, hide the add button with css and put an button below with an onClick on it?

@etodanik
Copy link

Actually this is required for me too. My use case is a form that will be displayed via an iFrame.
I need to hook myself onto anything that changes the document size and report it to the parent window.

@airdrik
Copy link

airdrik commented Feb 17, 2015

I've also got a use for this (or similar):
I've got a schema for json documents which describe a grid-like structure with rows and columns. Some of the rows only contain some of the columns.
In the sub-form for the rows I want to display a list of the columns so the user can select which columns the row contains. As such I need to keep the list of columns in the rows sub-form in sync with the list of columns from the columns sub-form.
e.g.

    [
        { key: "columns", type: "tabarray",
            onChange: updateRowColumns() // or onAdd/onRemove, or whatever
        },
        { key: "rows", type: "tabarray", items: [
            "rows[].rowIdentifier",
            {
                key: "rows[].columns", // currently implemented as a list of indexes into the columns array
                type: "checkboxes",
                titleMap: buildFromColumns() // list of {value: columnIdx, name: column.name} for the checkboxes
            }
        ]}
    ]

I tried just using the onChange on the columns tabarray and it didn't trigger when adding or removing columns.

@airdrik
Copy link

airdrik commented Mar 9, 2015

Is there any way to listen to changes to the size of an array or tabarray form element?
Or would it be easier to set up some kind of watch on the underlying array object?

@davidlgj
Copy link
Contributor

There is currently no way to listen to changes of the array, so a $watch on the underlying object is your only choice until onChange is implemented for arrays.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants