swipebox icon indicating copy to clipboard operation
swipebox copied to clipboard

jQuery 3.0 support?

Open jovilog opened this issue 8 years ago • 18 comments

With jQuery 3.0 a click anywhere on the page initializes an empty Swipebox that can't be closed again. Seems like a compatibility issue. Will Swipebox support jQuery 3.0?

jovilog avatar Jun 29 '16 09:06 jovilog

same Error. Did you find a solution

JWPapi avatar Jun 29 '16 13:06 JWPapi

Sorry, no.

jovilog avatar Jun 29 '16 15:06 jovilog

I've found the cause of the problem: https://api.jquery.com/selector/ Doesn't look like a quick fix.

andrews05 avatar Jul 01 '16 09:07 andrews05

Any comment from the author, please?

jovilog avatar Jul 06 '16 09:07 jovilog

last update is almost 4 month old. I think we should look for alternatives

JWPapi avatar Jul 06 '16 09:07 JWPapi

hey there,

I didn't found a solution yet. I will update the plugin as soon as I got it. Any help here will be greatly appreciated.

brutaldesign avatar Jul 06 '16 11:07 brutaldesign

My suggestion would be to specify the "selector" in the options and the user would initialise by targeting (e.g.) the body rather than the links, like $(body).swipebox({selector:'.swipebox'}). This would only be for dynamic content, if you didn't need it to be dynamic you would just do it the normal way. This is how Bootstrap does it for things like popovers.

So rather than $( document ).on( 'click', selector, ... it would be $( elem ).on( 'click', settings.selector, .... And then instead of $elem = $( selector ) it would be $elem = $( elem ).find( settings.selector ), or if selector wasn't specified it would just be $elem = $( elem ).

[EDIT] To all readers looking for a fix, please ignore this post and see PR #298.

andrews05 avatar Jul 06 '16 21:07 andrews05

Hm, thanks for the work, but calling it with $(body).swipebox({selector:'.swipebox'}) as the user seems odd to me. Is this really the way to go?

jovilog avatar Jul 07 '16 12:07 jovilog

Yes it is, but only if you're working with dynamic content where elements may be added on the fly and you don't want to reinitialise Swipebox. Otherwise just carry on doing it the normal way.

andrews05 avatar Jul 07 '16 18:07 andrews05

The jQuery migrate plugin reports bind/unbind as deprecated, so it may also be good to change all of these to on/off just to be safe.

andrews05 avatar Jul 07 '16 18:07 andrews05

Yes, but with jQuery 3.0, I cannot carry on. Any other solution ?

krunalrohit avatar Jul 16 '16 08:07 krunalrohit

to make plugin works it is not enough to call plugin as described before $(".swipebox").swipebox({ selector: '. swipebox' }); you need to add one more line of code: around line #70 after plugin.settings = $.extend( {}, defaults, options ); add selector = plugin.settings.selector;

zhaabbaa avatar Aug 19 '16 13:08 zhaabbaa

@zhaabbaa you need to apply the pull request referenced above (#298).

andrews05 avatar Aug 19 '16 22:08 andrews05

I can confirm that the PR in #298 works for me with jQuery 3.1.0 - thanks!

leewillis77 avatar Sep 06 '16 15:09 leewillis77

#298 works with jQuery 3.1.0. Thanks!

netAction avatar Sep 09 '16 09:09 netAction

@brutaldesign Any news on this?

nynsen avatar Dec 16 '16 13:12 nynsen

This fix works on jQuery 3.2.1 when called with the extra selector.

sebgmc avatar Nov 29 '17 20:11 sebgmc

My old version still works fine, but when I updated to the new version, it gave me an error message. Every time I pressed start, it showed a black screen, and there was no way to close it. I'm applying it but it's still giving an error, do you have any specific description, or am I doing something wrong: { "version": "1.0", "defaultProvider": "cdnjs", "libraries": [

{
  "provider": "cdnjs",
  "library": "[email protected]",
  "destination": "wwwroot/lib/jquery.swipebox/",
  "files": [
    "js/jquery.swipebox.min.js",
    "js/jquery.swipebox.js"
  ]
},
{
  "provider": "cdnjs",
  "library": "[email protected]",
  "destination": "wwwroot/lib/jquery.swipebox/"
},
{
  "provider": "cdnjs",
  "library": "[email protected]",
  "destination": "wwwroot/lib/jqueryui/",
  "files": [
    "jquery-ui.min.js",
    "themes/base/jquery-ui.css",
    "themes/base/jquery-ui.min.css",
    "jquery-ui.js"
  ]
},
{
  "provider": "cdnjs",
  "library": "[email protected]",
  "destination": "wwwroot/lib/jquery/",
  "files": [
    "jquery.min.js",
    "jquery.js"
  ]
}

] } image

Hoai-Phong avatar Apr 09 '24 02:04 Hoai-Phong