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

feat(gridster): add ability to remove widgets via a clickable icon #398

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

switchtrue
Copy link

Optionally, the gridster widget can be configured to display an icon at the top right of each widget which, when clicked, removes the widgets from the board.

@joshribakoff
Copy link

Hmm I think something like this is better left up to the user, and instead focus this lib on providing a better API. As a user I'm always going to want to customize the HTML (for example to add an "id" for each element via an html5 data attribute). I like that this stuff is left up to the user.

What I don't like is that a user I have to do stuff like:

// Sorting is necessary to prevent bugs in following "offset calculation" if not doing rows in order
s = Gridster.sort_by_row_and_col_asc(s);

Instead of adding new UI elements, I'd rather see the API cleaned up, so as a user I can add new UI elements on my own. Just my 2 cents from someone who only first used gridster 1 day ago.

@Bigismall
Copy link

You should use delegated events in removable method. Thanks to it removing elements will work with dynamically added elements.

Use this

   this.$el.on("click", "li ."+this.remove_handle_class, function(event) {
       if (ui.remove_enabled) {
           $player = $(event.target).closest('.gs-w');
           ui.remove_widget($player, ui.options.remove.silent, ui.options.remove.on_complete);
       }
   });

instead of that

   this.$el.find('li .' + this.remove_handle_class).click(function(event) {
       if (ui.remove_enabled) {
           $player = $(event.target).closest('.gs-w');
           ui.remove_widget($player, ui.options.remove.silent, ui.options.remove.on_complete);
       }
   });

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.

3 participants