ArcBees / gwtquery

A jQuery clone for GWT, and much more.
MIT License
85 stars 38 forks source link

empty() #305

Closed biancashouse closed 9 years ago

biancashouse commented 9 years ago

empty() should remove the element's children, but NOT the element itself.

my workaround is my own version:

empty(GQuery qEl) { qEl.children().remove(); }

christiangoudreau commented 9 years ago

Acknowledged, you're right!

http://api.jquery.com/empty/

meriouma commented 9 years ago

Which version of GQuery are you using? What is your selector? What does your DOM looks like?

biancashouse commented 9 years ago

Right now, I don't have any use of empty(), because I coded up my workaround, but I was using selectors like:

"#col1 .panel-body"

i.e. I'm reusing bootstrap panels, and in order to clear them out before I repopulate them, I wanted to use empty().

Although, I think totally unrelated, I'm also making use of compile time selectors like this..

import com.google.gwt.query.client.GQuery; import com.google.gwt.query.client.Selector; import com.google.gwt.query.client.Selectors;

public interface I_TPD_Selectors extends Selectors {

@Selector("#login-panel") GQuery qTheLoginPanel();

@Selector("#programs-panel") GQuery qTheProgramsPanel();

@Selector("#topics-panel") GQuery qTheTopicsPanel();

@Selector("#tests-panel") GQuery qTheTestsPanel();

@Selector("#instructions-panel") GQuery qTheInstructionsPanel();

@Selector("#yesno-q-panel") GQuery qTheYesNoQuestionPanel();

@Selector("#selection-q-panel") GQuery qTheSelectionQuestionPanel();

@Selector("#dnd-q-panel") GQuery qTheDnDQuestionPanel();

@Selector("#programs-panel > .panel-heading") GQuery qTheProgramsPanelHeader();

@Selector("#programs-panel > .panel-body") GQuery qTheProgramsPanelBody();

@Selector("#programs-panel > .panel-footer") GQuery qTheProgramsPanelFooter();

@Selector("#topics-panel > .panel-heading") GQuery qTheTopicsPanelHeader();

@Selector("#topics-panel > .panel-body") GQuery qTheTopicsPanelBody();

@Selector("#topics-panel > .panel-footer") GQuery qTheTopicsPanelFooter();

@Selector("#tests-panel > .panel-heading") GQuery qTheTestsPanelHeader();

@Selector("#tests-panel > .panel-body") GQuery qTheTestsPanelBody();

@Selector("#tests-panel > .panel-footer") GQuery qTheTestsPanelFooter();

@Selector("#instructions-panel > .panel-heading") GQuery qTheInstructionsPanelHeader();

@Selector("#instructions-panel > .panel-body") GQuery qTheInstructionsPanelBody();

@Selector("#instructions-panel > .panel-footer") GQuery qTheInstructionsPanelFooter();

@Selector("#yesno-q-panel > .panel-heading") GQuery qTheYesNoQuestionPanelHeader();

@Selector("#yesno-q-panel > .panel-body") GQuery qTheYesNoQuestionPanelBody();

@Selector("#selection-q-panel > .panel-heading") GQuery qTheSelectionQuestionPanelHeader();

@Selector("#selection-q-panel > .panel-body") GQuery qTheSelectionQuestionPanelBody();

@Selector("#dnd-q-panel > .panel-heading") GQuery qTheDndQuestionPanelHeader();

@Selector("#dnd-q-panel > .panel-body") GQuery qTheDndQuestionPanelBody();

@Selector("button#imready") GQuery qTheImReadyButton();

@Selector("#col1") GQuery qCol1();

@Selector("#col2") GQuery qCol2();

@Selector("#col3") GQuery qCol3();

}

On Mon, Nov 10, 2014 at 1:50 PM, Maxime Meriouma-Caron < notifications@github.com> wrote:

What is your selector? What does your DOM looks like?

— Reply to this email directly or view it on GitHub https://github.com/ArcBees/gwtquery/issues/305#issuecomment-62334736.

Ian White h: +61 2 9948 9739 m: +61 404 950 122 skype (home): biancashouse

biancashouse commented 9 years ago

Chris,

Just noticed, slideLeft and slideRight missing from GQuery. They are convenience methods, like slideUp and slideDown. They are still available if you use the Effects class directly, so not a show stopper.

Thanks

Ian

On Mon, Nov 10, 2014 at 4:15 PM, Ian White ian@biancashouse.com wrote:

Right now, I don't have any use of empty(), because I coded up my workaround, but I was using selectors like:

"#col1 .panel-body"

i.e. I'm reusing bootstrap panels, and in order to clear them out before I repopulate them, I wanted to use empty().

Although, I think totally unrelated, I'm also making use of compile time selectors like this..

import com.google.gwt.query.client.GQuery; import com.google.gwt.query.client.Selector; import com.google.gwt.query.client.Selectors;

public interface I_TPD_Selectors extends Selectors {

@Selector("#login-panel") GQuery qTheLoginPanel();

@Selector("#programs-panel") GQuery qTheProgramsPanel();

@Selector("#topics-panel") GQuery qTheTopicsPanel();

@Selector("#tests-panel") GQuery qTheTestsPanel();

@Selector("#instructions-panel") GQuery qTheInstructionsPanel();

@Selector("#yesno-q-panel") GQuery qTheYesNoQuestionPanel();

@Selector("#selection-q-panel") GQuery qTheSelectionQuestionPanel();

@Selector("#dnd-q-panel") GQuery qTheDnDQuestionPanel();

@Selector("#programs-panel > .panel-heading") GQuery qTheProgramsPanelHeader();

@Selector("#programs-panel > .panel-body") GQuery qTheProgramsPanelBody();

@Selector("#programs-panel > .panel-footer") GQuery qTheProgramsPanelFooter();

@Selector("#topics-panel > .panel-heading") GQuery qTheTopicsPanelHeader();

@Selector("#topics-panel > .panel-body") GQuery qTheTopicsPanelBody();

@Selector("#topics-panel > .panel-footer") GQuery qTheTopicsPanelFooter();

@Selector("#tests-panel > .panel-heading") GQuery qTheTestsPanelHeader();

@Selector("#tests-panel > .panel-body") GQuery qTheTestsPanelBody();

@Selector("#tests-panel > .panel-footer") GQuery qTheTestsPanelFooter();

@Selector("#instructions-panel > .panel-heading") GQuery qTheInstructionsPanelHeader();

@Selector("#instructions-panel > .panel-body") GQuery qTheInstructionsPanelBody();

@Selector("#instructions-panel > .panel-footer") GQuery qTheInstructionsPanelFooter();

@Selector("#yesno-q-panel > .panel-heading") GQuery qTheYesNoQuestionPanelHeader();

@Selector("#yesno-q-panel > .panel-body") GQuery qTheYesNoQuestionPanelBody();

@Selector("#selection-q-panel > .panel-heading") GQuery qTheSelectionQuestionPanelHeader();

@Selector("#selection-q-panel > .panel-body") GQuery qTheSelectionQuestionPanelBody();

@Selector("#dnd-q-panel > .panel-heading") GQuery qTheDndQuestionPanelHeader();

@Selector("#dnd-q-panel > .panel-body") GQuery qTheDndQuestionPanelBody();

@Selector("button#imready") GQuery qTheImReadyButton();

@Selector("#col1") GQuery qCol1();

@Selector("#col2") GQuery qCol2();

@Selector("#col3") GQuery qCol3();

}

On Mon, Nov 10, 2014 at 1:50 PM, Maxime Meriouma-Caron < notifications@github.com> wrote:

What is your selector? What does your DOM looks like?

— Reply to this email directly or view it on GitHub https://github.com/ArcBees/gwtquery/issues/305#issuecomment-62334736.

Ian White h: +61 2 9948 9739 m: +61 404 950 122 skype (home): biancashouse

Ian White h: +61 2 9948 9739 m: +61 404 950 122 skype (home): biancashouse

christiangoudreau commented 9 years ago

Thanks for pointing that out!

meriouma commented 9 years ago

I've done a few tests and it seems to be working fine. Are you sure your selector isn't matching the parent too? Can you should a more complete example use case that isn't working, with the DOM you are targeting?

jDramaix commented 9 years ago

Yep I confirm that empty() doesn't remove the element, only the children of the elements. So if you element is removed after calling the empty() method it's because one of its parents is selected by your selector.