GithubHelp home page GithubHelp logo

Comments (19)

shehi avatar shehi commented on June 10, 2024

There are two JS files in /dist folder, one is standalone (without jQuery), the other is bundled with jQuery. Which one are you using? If you are using standalone one, make sure you also include jQuery somewhere before it.

This package isn't really NPM module compatible, more like a classic JS package - it won't require (i.e. import) jQuery even when jQuery is listed as a dependency. You will have to import jQuery manually. The reason I included bundled one, was actually to show the users an example to how concatenate and bundle this package with other packages (by providing a Docker env and Gulp integration).

from uniform.

justinmz avatar justinmz commented on June 10, 2024

It should be the standalone version.
Also I'm using webpack for the first time and including it like this.

import $ from "jquery";
var uniformJs = require("uniform-js");

Jquery is definitely there because it's being used for something else.
Might just be that I'm including your script incorrectly?

from uniform.

shehi avatar shehi commented on June 10, 2024

I believe this package is named "jquery.uniform", not "uniform-js"...

from uniform.

shehi avatar shehi commented on June 10, 2024

And... requiring it with Webpack (which I use in my other open source project as well, but not here) might not work: it'd import both JS files from /dist. Nah, main entry point in package.json is the standalone dist file.

Ok, I think I will have to remove bundled version after all... Hmm...

from uniform.

shehi avatar shehi commented on June 10, 2024

I will look into this, this weekend - let me know if you fix it and find some workaround it in the meantime.

from uniform.

imballinst avatar imballinst commented on June 10, 2024

@justinmz Hello, have you tried adding this plugin in your webpack.config.js?

new webpack.ProvidePlugin({
    $: "jquery",
    jQuery: "jquery",
    "window.$": "jquery",
    "window.jQuery": "jquery"
})

That will provide jquery to the dependencies that depend on jquery. Then, in your Javascript file:

import 'jquery.uniform'; //the same as 'jquery.uniform/dist/js/jquery.uniform.standalone'; 
import 'jquery.uniform/dist/css/default.css';

$("select, input:checkbox, input:radio, input:file").uniform();

That works for me. Let me know if the problem persists! :D

from uniform.

justinmz avatar justinmz commented on June 10, 2024

Hey, we ended up including jQuery globally as we needed it across most of our templates which solved the problem for us.

from uniform.

shehi avatar shehi commented on June 10, 2024

Thanks for feedback.

from uniform.

zuhriyansauqi avatar zuhriyansauqi commented on June 10, 2024

@imballinst should it works with jquery 3.x.x?

from uniform.

imballinst avatar imballinst commented on June 10, 2024

@zuhriyansauqi I believe it does, I am using jQuery ^3.2.1 in my project and it works seamlessly (https://webpack.js.org/plugins/provide-plugin/)

from uniform.

zuhriyansauqi avatar zuhriyansauqi commented on June 10, 2024

@imballinst mine doesn't work. Using the same webpack setting as above and it says that uniform is not a function. :(

from uniform.

imballinst avatar imballinst commented on June 10, 2024

@zuhriyansauqi What are the version of your jquery and jquery-uniform? Mine are these:

dependencies: {
    ...
    "jquery": "^3.2.1",
    "jquery.uniform": "^4.2.0",
   ....
}

from uniform.

zuhriyansauqi avatar zuhriyansauqi commented on June 10, 2024

@imballinst

dependencies: {
    ...
    "jquery": "^3.2.1",
    "jquery.uniform": "^4.2.0",
   ....
}

same as yours..
I'm using the latest version.

when i call $('.styled').uniform(), it give me an error.

from uniform.

imballinst avatar imballinst commented on June 10, 2024

Ah, I see. I guess the problem is not in the Webpack, then. Maybe you don't import jquery-uniform correctly? I import it in my entry file, because it works globally across all my modules. How and where do you import it? Also make sure that jquery is imported before jquery-uniform

from uniform.

zuhriyansauqi avatar zuhriyansauqi commented on June 10, 2024
import $ from 'jquery'
import 'select2'
import 'jquery.uniform'
componentDidMount() {
  $('.select').select2({ width: '100%' })
  $('.styled').uniform()
}
new webpack.ProvidePlugin({
jQuery: 'jquery',
  $: 'jquery',
  jquery: 'jquery',
  'window.$': 'jquery',
  'window.jQuery': 'jquery'
})

@imballinst

from uniform.

imballinst avatar imballinst commented on June 10, 2024

Ah, you are using it with React, I see. I will need to try it first (because I haven't tried it yet in React), I thought you were trying it with plain HTML or something. I'll inform you when I'm done!

from uniform.

imballinst avatar imballinst commented on June 10, 2024

This works for me @zuhriyansauqi

...
import $ from 'jquery';
import 'jquery.uniform';
import 'jquery.uniform/dist/css/default.css';
...

class Test extends React.Component {
  componentDidMount() {
    $('.xd').uniform();
  }

  render() {
    return (
      <form>
        <input className="xd" type="checkbox" />
        <button>submit</button>
      </form>
    );
  }
}

render(
  <Test />,
  document.getElementById('test-div')
);

Without Uniform:
Screenshot Test1
With Uniform:
Screenshot Test2

I don't know actually what went wrong for you. Did you use CommonChunksPlugin and forget to include the chunk(s) in your HTML/template file? Also, have you tried to removing node_modules and do another npm install?

from uniform.

meliborn avatar meliborn commented on June 10, 2024

Have the same issue with Vue.js
Webpack config:

const webpack = require('webpack');

module.exports = {
  configureWebpack: {
    plugins: [
      new webpack.ProvidePlugin({
        $: 'jquery',
        jQuery: 'jquery',
        'window.$': 'jquery',
        'window.jQuery': 'jquery'
      })
    ]
  }
}

Using in component:

import $ from 'jquery';
import 'jquery.uniform';

export default {
  name: 'CheckBox',
  mounted(){
    $(this.$refs.unifyCheckBox).uniform({
        radioClass: 'choice'
    });
  }
}

resta-crm-vue 2018-06-13 15-28-08

   "jquery": "^3.3.1",
    "jquery.uniform": "^4.2.2",

from uniform.

vesper8 avatar vesper8 commented on June 10, 2024

@meliborn did you ever figure it out? I'm also using Vue and Uniform is giving me so much pain!! I can't even get it to work if I include the scripts normally.. and I would much rather import it into my components.. how did you solve it in the end?

from uniform.

Related Issues (20)

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.