Skip to content
This repository has been archived by the owner on Apr 16, 2019. It is now read-only.

Missing .clone() API? #48

Closed
abereznyi opened this issue Jan 27, 2012 · 12 comments
Closed

Missing .clone() API? #48

abereznyi opened this issue Jan 27, 2012 · 12 comments

Comments

@abereznyi
Copy link

I don't see an API call similar to jQuery .clone() method.

Is there anything like it in jQ.Mobi?

I use it a lot to build lists dynamically.

Thanks,
Alex

@Indiepath
Copy link

It's in the new release.

@abereznyi
Copy link
Author

I see clone() in 0.9.1a but it seems to return an HTML element instead of a set.
Seems like a bug to me.

@Indiepath
Copy link

What do you mean by "set" do you mean a deep clone?

@abereznyi
Copy link
Author

By "set" I mean jQuery selector result type to which one can apply jQuery methods.

In jQuery I can write:

var a = $('#someid').clone(); a.removeAttr('id');

but in jQ.Mobi I have to extra wrap .clone() result in $() to do same:

var a= $($('#someid').clone()); a.removeAttr('id');

@Indiepath
Copy link

I see what you mean so you basically want to be able to chain :

$('#someid').clone().removeAttr('id');

I'm sure Ian can manage this, I had a similar request with $('#someid').parent().addClass('blah'); - he sorted it in 2 mins :)

@abereznyi
Copy link
Author

Also .clone() is a deep clone in jQuery - can you make it so in jQ.Mobi?
it's not very useful now without deep cloning.

@imaffett
Copy link
Contributor

clone takes in a parameter "deep" which will copy in all the children. It does not copy events (nor will it).

@abereznyi
Copy link
Author

No events copy is fine, but I'd like to see same behavior as jQuery, where deep=true by defaul.
I am trying to port an app from jQuery and such incompatibilities waste a lot of my debugging time.

Thanks,
Alex

@imaffett
Copy link
Contributor

Got it...I'll make that change. Thanks!

@abereznyi
Copy link
Author

BTW, you are also missing jQuery ().data() API ...

@Indiepath
Copy link

Hardly - it's only an attribute :) But In know what you mean.

$(''selector").attr("data-twaddle");

@imaffett
Copy link
Contributor

imaffett commented Feb 1, 2012

Actually it's in the code and has been, just not documented. You get points though because evidently you're the only one to read the actually Readme.md file ;)

We'll have better documentation for the 1.0 release.

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

No branches or pull requests

3 participants