surveyjs / survey-library

Free JavaScript form builder library with integration for React, Angular, Vue, jQuery, and Knockout.
https://surveyjs.io/form-library
MIT License
4.21k stars 815 forks source link

barrating question not working in React #4334

Open OpsDev8 opened 2 years ago

OpsDev8 commented 2 years ago

Are you requesting a feature, reporting a bug or asking a question?

bug

What is the current behavior?

I want to add a stars rating question (type "barrating") to my React project, and unfortunately only this type of question doesn't work (the qusetion doesn't shown).

I see that you have the same problem in your documention for React: https://codesandbox.io/s/jjp6ro (There is no visible page or question in the survey.)

while for Vue (for example), it's working: https://codesandbox.io/s/o3exvy

Hope that you have any quick solution for this problem. Thanks!

Specify your

andrewtelnov commented 2 years ago

@OpsDev8 Please comment this line: //window["$"] = window["jQuery"] = $;

Thank you, Andrew

OpsDev8 commented 2 years ago

Thank you for your response, but this use-case not relevant for us.

This is how we are using it:


import { Survey } from 'survey-react';

...

const form = {
  "pages": [
    {
      "name": 'myForm',
      "elements": {[
        "type": 'barrating',
        "name": 'myBarrating',
        "choices": ["1", "2", "3", "4", "5"],
        "ratingTheme": "fontawesome-stars",
        "title": "1",
        "isRequired": true
      ]}
    }
  ]
}

...

const surveyRender = (<Survey
  json={form}
  showCompletedPage={false}
  onComplete={handleComplete}
/>)

...

return (
  <div>
    {
      surveyRender
    }
  </div>
)

So we don't have this line in our code, and we don't understand why this spesific question not working for us while radiogroup question or checkbox question is working fine.

Hope that it is more accurate and understandable now. Thank you.

andrewtelnov commented 2 years ago

@OpsDev8 I have updated the example to make it works.

Thank you, Andrew

OpsDev8 commented 2 years ago

We don't understand what did you change in the example and how it's relevant to the example code we attached.

We will be glad for clarification and help solve the problem in our use case.

Thanks.

andrewtelnov commented 2 years ago

window["$"] = window["jQuery"] = $; code should be above import * as widgets from "surveyjs-widgets";

Thank you, Andrew

OpsDev8 commented 2 years ago

Thank you, but I'm saying that we are not using the library in this way and we don't have this line on our code. PLEASE see the attached code above.

If you can help us to solve the problem in our use case or give us any path to a solution it will be great.

Thanks.

andrewtelnov commented 2 years ago

@OpsDev8 Could you please create the example with your code? You initially rely on our examples.

Thank you, Andrew

OpsDev8 commented 2 years ago

https://codesandbox.io/s/elated-knuth-khuctt

This is an example of how we are using it and you can see that it's not working.

Hope that you can help us, Thanks!

andrewtelnov commented 2 years ago

@OpsDev8 In your example you do not include any script related to barrating. We do not have barrating out of the box and in our example we show how to use third-party JavaScript widget in our library.

Thank you, Andrew