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

Added a "display_on_attach" option. #75

Open
wants to merge 3 commits into
base: dev
Choose a base branch
from
Open

Added a "display_on_attach" option. #75

wants to merge 3 commits into from

Conversation

dc-m
Copy link

@dc-m dc-m commented Sep 20, 2017

This allows you to set true or false. If true it will show all available unfiltered items. If false it will not show any item until you start typing (like original).

This allows you to set true or false. If true it will show all available unfiltered items. If false it will not show any item until you start typing (like original).
@hakib
Copy link
Owner

hakib commented Sep 20, 2017

Hey @dc-m, Thanks for the PR!

The diff is very hard to read (is it possible you formated the entire file?).

I left some comments but I might have missed some changes as all the file is marked as changed. If you could push an update that will highlight only the changes you made it will be much easier for me to review.

@dc-m
Copy link
Author

dc-m commented Sep 20, 2017

Sure I will do that when i get back from work tonight - sorry i CTRL + K + D and it must have caused a whole file reshift!


value_watch = $scope.$watch(
function () {
if (current_options.display_on_attach && ngmodel.$modelValue == null) ngmodel.$modelValue = "";
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change

$scope.selected_index = 0;
$scope.waiting_for_suggestion = true;

if (typeof(term) === 'string' && term.length > 0 || current_options.display_on_attach) {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

change

@dc-m
Copy link
Author

dc-m commented Sep 25, 2017

Apologies for the way I've done this.

I attempted to get it to only show my changes but each time I did it seems to just remove all the original and add all my file. So have commented where I have made changes

bind_element();

//Added to ensure on attach if value there it doesnt try reset to all - DAVID 08/06/2017
if (current_element[0].value.length == 0) suggest("", current_element);;
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change

@hakib
Copy link
Owner

hakib commented Sep 27, 2017

Hey David,

A more general approach would be "suggest_when_empty" option. This way you we can also address the situation where the user deleted all the text from the input and you want to trigger a suggest cycle to show some options.

If you set last_selected_value to null in on_attach for example, it will trigger a suggest cycle when you first focus the field (given that there is no value to the ngModel).

        if (options.suggest_when_empty) {
          // Set last value to something different than th initial value
          // so the first suggest will trigger suggest.
          last_selected_value = null;
        }

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

Successfully merging this pull request may close these issues.

2 participants