Giter VIP home page Giter VIP logo

Comments (5)

paulalex avatar paulalex commented on September 26, 2024

Error fires on page load when placed inside a call to document.ready and error fires on button click when not placed inside call to document.ready. Call to switchButton is as follows:

$("#count").switchButton({
on_label: 'count',
off_label: '%',
labels_placement: 'left',
width: 50,
height: 20,
button_width: 20
});

from jquery-switchbutton.

paulalex avatar paulalex commented on September 26, 2024

I do not know the cause of this issue but I have managed to get it to work using the following method inside a call to document.ready:

$(function() {
$( "#count_percent" ).append( "<input type="checkbox" value="true" id="count" checked>" );
$("#count").switchButton({
on_label: 'count',
off_label: '%',
labels_placement: 'left',
width: 50,
height: 20,
button_width: 20
});
});

My best guess is that this has something to do with the fact that the code is generated server side using jsp includes tags and is rendered by the spring framework.

from jquery-switchbutton.

olance avatar olance commented on September 26, 2024

Hi,

thanks for your report!

Is there anywhere in your code where you would call $("#count").switchButton("option", "xxxxx", yyy) ?

The error message you pasted in your first message suggests that you're trying to get the value of a switchbutton option, or change it, before it has actually been initialized.
This is a jQuery UI error. You probably have code somewhere that is executed before the button is actually initialized.

from jquery-switchbutton.

paulalex avatar paulalex commented on September 26, 2024

Hi, I dont specifically make a call to that myself. I just copied the examples from your demo page. I tried them on my main page which has a lot of javascript and html and is serverside generated and got the issue.

When I moved just this bit out to a standard html file I no longer got the issue so I figured it had to be to do with the order of loading of elements or scripts. Firebug showed everything loaded and there were no other issues but I imagine this would be pretty difficult to replicate.

I found a workaround which I posted above which works as I guess it puts the element into the dom and then fires a call to your function to set the slider. This seems to work and the slider performs as I would expect in both IE and firefox (which is all we support for our userbase) so I am more than happy!

Thanks!

from jquery-switchbutton.

olance avatar olance commented on September 26, 2024

Okay, so this is indeed more likely to be a problem linked to how your page is rendered rather than a problem of the plugin itself ^^

I'm glad to see someone's using it though :)

from jquery-switchbutton.

Related Issues (14)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.