Flyer53 / jsPanel

A jQuery Plugin to create highly configurable floating panels, modals, tooltips and hints/notifiers for use in a backend solution and other web applications.
http://v2.jspanel.de/
Other
163 stars 56 forks source link

get jsPanel object by id (3.0 Beta) #60

Closed night507 closed 8 years ago

night507 commented 8 years ago

Hello again :-) I couldn't find anything about this in the documentation or resolved issues. Is there a way to get the object of a specific jsPanel by id, so i could execute e.g. .close() on it? In my case i'm using w2ui form to display content in the jsPanel. The buttons that are included in the form have to control the jsPanel. At the moment i'm referencing the complete jsPanel object to the form, in order to close it in the functions of the form-buttons, which is not really pretty, but it works. Is there something like:

var panel_id = 'jsPanel-1'; var panel = $.jsPanel[panel_id]; panel.close();

So i could only add the id of the panel to my form?

Flyer53 commented 8 years ago

Hi there, I don't nderstand why you have to reference a panel by id. Why don't you assign the whole jsPanel to a variable and call the close method on the variable?

var panel = $.jsPanel({
  id: 'mypanel',
  // rest of your panel config
});
panel.close();

You can call panel.close() from anywhere within the panel as well. Isn't that what you want to do?

Or if you really need to use the id you could trigger a click on the close button from somewhere in your code like:

$('.jsPanel-btn-close', '#mypanel').trigger('click');
night507 commented 8 years ago

Triggering the close button works great. Thanks :) -> closed