Skip to content
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

Return the selected button value along with the button index #9

Open
Beagle25 opened this issue Sep 27, 2014 · 6 comments
Open

Return the selected button value along with the button index #9

Beagle25 opened this issue Sep 27, 2014 · 6 comments

Comments

@Beagle25
Copy link

Could you please alter the show() callback to return both the selected button value and button index?

This would help out tremendously when dealing with dynamically generated action sheets.

Thank you!

@fernandopg
Copy link

+1 Can it be done now? Thanks!

@EddyVerbruggen
Copy link
Owner

I'm not sure why you need it exactly - you should be able to track the indexes and values in javascript as well.

Also, adding the value to the callback would break current usage.

@fernandopg
Copy link

It helps you when you create the action sheets dynamically and you don't know how much options you have nor the index for each option.

Another option could be if you can assign manually the index number for each option!

@EddyVerbruggen
Copy link
Owner

Can you show me an example of a dynamically created actionsheet where it's not possible to remember which item was added in which order?

@fernandopg
Copy link

Of course @EddyVerbruggen , here I have an example with a user that can do different things if is owner of the table or not, and depends of a table status also. I don't say that it is impossible to know the order in case of dynamic created actionsheet but I think that helps you a lot if you can read the button value or if each option has a defined index and the order doesn't matter.

var buttonsLabel = ['View'];

// if owner
if (user.id === table.owner) {
  switch (table.status) {
    case 'new':
      buttonsLabel.push('Delete');
      break;
    case 'edited':
      buttonsLabel.push('Copy', 'Delete', 'Save');
      break;
    case 'deleted':
      buttonsLabel.push('Restore', 'Delete forever');
      break;
  }
  if (status === 2) {
    buttonsLabel.push('View');
  }
// not owner
} else {
  switch (table.permissions) {
    case 'read':
      buttonsLabel.push('Copy');
      break;
    case 'write':
      buttonsLabel.push('Delete', 'Save');
      break;
  }
}

window.plugins.actionsheet.show({
  'title': "Actions",
  'buttonLabels': buttonsLabel,
  'androidEnableCancelButton' : true,
  'addCancelButtonWithLabel': 'Cancel'
}, _.bind(this.onActionSheet, this));

Anyway, if is not possible no problem! The plugin is awesome and I can workaround that without problem!

Thanks and sorry for my bad English... ;-)

@sjosen
Copy link

sjosen commented Aug 5, 2016

@fernandopg Have you figured out a way to deal with dynamic loaded labels? I have the exact same problem as you describe

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

No branches or pull requests

4 participants