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

It is impossible to revert effect of $.fn.model(m) #101

Open
LazyDev2k opened this issue Dec 9, 2011 · 5 comments
Open

It is impossible to revert effect of $.fn.model(m) #101

LazyDev2k opened this issue Dec 9, 2011 · 5 comments

Comments

@LazyDev2k
Copy link
Contributor

The method $.fn.model(m) does two things:

  1. Adds a model instance to $.data(element, "models")
  2. Adds a model-specific class to the element

Unfortunately there is no convenient way to undo this. So if we bound a model to element we can't unbind it (and replace with other model).

I think that there should be a method like $.fn.unbindModel(m) that will revert effect of the $.fn.model(m).

@justinbmeyer
Copy link
Member

Why do you need this? Typically, if I am swapping a model on an instance, it's through a controller.

@daffl
Copy link
Contributor

daffl commented Dec 9, 2011

Do you mean something like

$('#element').model('remove');

Or maybe

$('#element').model(null);

?

@LazyDev2k
Copy link
Contributor Author

I mean

$('#element').model(null);
However this will never work because effect of $.fn.model depends on type of specified model.

@justinbmeyer
Copy link
Member

null could remove all model instances (found in data.models)

Buuuuuuuuuuuuuuuut ... I'd still like to know why you need this.

@LazyDev2k
Copy link
Contributor Author

We have an analog of select control. User may select any value of the list. We decided to bind selected value (instance of $.Model) to the select itself. And this worked quite well. However we met a case when we need to clear selection. So this ticket came to life.

I can believe that this may be not intended usage of $.fn.model method but in our case it seemed to be the most appropriate. Correct me, if I'm not right.

Also please notice that I not need to remove all model instances but only a specific one.

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

3 participants