Git Product home page Git Product logo

Comments (9)

isteven avatar isteven commented on August 22, 2024 1

Try this:

$scope.$watch( 'methodDropDownOptions' , function() {
    alert( 'hey, I am changed!' );
}, true );

from angular-multi-select.

isteven avatar isteven commented on August 22, 2024

Hi rajulkansara,

  1. Not planning to do this, but you can get (almost) similar result by
    combining the max-labels attribute and set the button width in the CSS.

  2. Validate your model before you process the data. For example, before you
    save your form, you can loop over your input-model and check if at least
    one of the model's tick-property is true.

On Wed, Jun 18, 2014 at 3:42 AM, rajulkansara [email protected]
wrote:

How to achieve fix width of dropdown no matter what is selected. If
selected options text width is big, it will show ... after truncated text.
If it is small it would show empty space.
2.

A Dropdown with multiple select option where at least one option must
be selected. (A kind of Mix of Radio and Check-box Behavior)


Reply to this email directly or view it on GitHub
#22.

from angular-multi-select.

rajulkansara avatar rajulkansara commented on August 22, 2024

For Number 2, i understood what you are advising. This has gave me hint that everytime any option is clicked i listen to to those changes and according i can achive alteast one option is selcted. But i did not find and event that is fire on every time i clicked on option. Do onChange will fire on model? or Any other specific event would fire on selecting or deselecting option?

from angular-multi-select.

isteven avatar isteven commented on August 22, 2024

There's no onChange event because you can simply use $watch in your
controller to watch changes in the input model $scope variable. The
directive will update the input model as you select / deselect a checkbox.

But the question is, why do you need to validate things on change? You can
always validate before you save your form.
On Jun 18, 2014 9:51 PM, "rajulkansara" [email protected] wrote:

For Number 2, i understood what you are advising. This has gave me hint
that everytime any option is clicked i listen to to those changes and
according i can achive alteast one option is selcted. But i did not find
and event that is fire on every time i clicked on option. Do onChange will
fire on model? or Any other specific event would fire on selecting or
deselecting option?


Reply to this email directly or view it on GitHub
#22 (comment)
.

from angular-multi-select.

rajulkansara avatar rajulkansara commented on August 22, 2024

It is a UX. Validation on submit would waste my few click rather i want user to realize that he would have to have select at least one check box.

from angular-multi-select.

isteven avatar isteven commented on August 22, 2024

I see.. Yes you have a valid purpose there. Anyway, does my suggestion to detect changes using $watch solve your problem?

from angular-multi-select.

rajulkansara avatar rajulkansara commented on August 22, 2024

I tried watch and watchcollection both in my controller. None of them worked. On Checking and Unchecking i am not getting below alert. Let me know where i am wrong.

HTML

Method:

-----Controller
$scope.methodDropDownOptions = [ { name: "Option1", ticked: true },{ name: "Option2", ticked: false }, { name: "Option3", ticked: false }

$scope.$watchCollection('methodDropDownOptions', function() {
alert('hey, I am changed!');
});

from angular-multi-select.

rajulkansara avatar rajulkansara commented on August 22, 2024

Yes it is working. Thanks.

from angular-multi-select.

isteven avatar isteven commented on August 22, 2024

You're welcome, glad the directive works for you.

I'll consider that onChange() callback ( or onItemClick() perhaps ).. Looks like it'll be useful for some, as using $watch with objectEquality == true on complex / big object actually has an adverse memory and performance implications - as stated in AngularJS website.

I'm closing this issue now. Feel free to open a new one anytime. Cheers.

from angular-multi-select.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.