Comments (9)
Hi Sam,
It should be marked as @deprecated in the source code.
Our source code is not an official source of information about available APIs. Please use documentation on our website.
from survey-library.
I completely agree that SurveyJS TypeScript definitions could be improved. However, this should be a well-planned and meticulous work—marking just one member as deprecated won't do. This work should take into account many factors, including necessary changes to our documentation-generating scripts. At the current moment, this isn't in our roadmap.
2 different properties, but internally they are the same:
onCanShowProperty
is an obsolete name for the onShowingProperty
event. It got into the docs by mistake. Thanks for pointing this out, we'll remove it.
Regarding your first question on this thread: I've updated the onPropertyChanged
and registerPropertyChangedHandlers
descriptions to clarify the difference between these API members in this PR: #8241. These changes will appear on our website with the next update. Since the main question has been addressed, I'm gonna close this issue. If you have any questions left, fell free to reopen it or create a new one.
Thanks!
from survey-library.
Hi @SamMousa,
Thank you for your inquiry. I would be in a better position to address your inquiry if you could elaborate on your usage scenario. Do you want to track property change in a creator?
I look forward to your reply.
from survey-library.
Both during survey creation and runtime.
(It's fine if there are different approaches for both)
from survey-library.
Thank you for the update.
- To handle changes of a survey and its elements' properties at design time, use the creator.onSurveyPropertyValueChanged event.
Regarding the runtime:
- You may wish to use the registerPropertyChangedHandlers function to implement a function which would fire on a property change of a Base SurveyJS object instance: a survey, question.
Consider the following code:
const popupSurveyModel = new Survey.PopupSurveyModel(null, survey);
popupSurveyModel.registerPropertyChangedHandlers(["isShowing"],
(newValue) => {
if(newValue === false)
alert("Popup is closed!");
});
Also, you may use the registerPropertyChangedHandlers
function to attach a function to a question object. Consider the following code:
options.question.registerPropertyChangedHandlers(["title"], function (newValue) {
//...
});
- The
survey.onPropertyChanged
event allows you to handle a property change of a survey object. - The registerFunctionOnPropertyValueChanged function is outdated and should not be used.
Please let me know if you have further questions.
from survey-library.
Yes, can you update the documentation?
The registerFunctionOnPropertyValueChanged function is outdated and should not be used.
It should be marked as @deprecated
in the source code.
To handle changes of a survey and its elements' properties at design time, use the creator.onSurveyPropertyValueChanged event.
If I want both, is there any harm in always using the survey.onPropertyChanged
?
You may wish to use the registerPropertyChangedHandlers function to implement a function which would fire on a property change of a Base SurveyJS object instance: a survey, question.
This seems like a duplicate functionality with respect to onPropertyChanged
, or am I misunderstanding?
It'd be great if there was some documentation pointing developers to the preferred implementation method. When I look at the code onPropertyChanged
uses a proper event implementation in a separate class, while registerPropertyChangedHandlers
seems to be an implementation that lives inside the base class.
I know I can use both; but please document somewhere (not just in an answer on this ticket) which considerations there are and which I should use.
from survey-library.
Hi Sam,
Thank you for the update.
It should be marked as @deprecated in the source code.
@RomanTsukanov, please take a look.
If I want both, is there any harm in always using the survey.onPropertyChanged?
The survey.onPropertyChanged
is raised when a survey object property is changed. However, this event won't be raised when a question property is changed. If you wish to handle the property change or survey and its elements in SurveyJS Creator, use the creator.onSurveyPropertyValueChanged event.
from survey-library.
I'm sorry but this kind of comment really makes no sense. You generate types in d.ts
files. Why generate them if they are not supposed to be used.
The more I try to interact with the code and try to help and improve it the more I get the feeling that SurveyJS is open source in name only...
If you look at the contributor graphs (https://github.com/surveyjs/survey-library/graphs/contributors) it's only your employees putting in the work and there's no attempt to grow the community part.
All suggestions I do objectively make the code better and in most cases I'm willing to do the legwork. But there's just so much resistance to outside contributions that it seems impossible to get thing merged.
Even if the source code is not an official source, it is still a source and it can be improved by marking something that you don't want code consumers to use with @internal
...
from survey-library.
Also, the documentation is inconsistent as well, for example this:
https://surveyjs.io/survey-creator/documentation/api-reference/survey-creator#onShowingProperty
https://surveyjs.io/survey-creator/documentation/api-reference/survey-creator#onCanShowProperty
2 different properties, but internally they are the same:
public onShowingProperty: EventBase<SurveyCreatorModel, PropertyAddingEvent> = this.addCreatorEvent<SurveyCreatorModel, PropertyAddingEvent>();
public onCanShowProperty: EventBase<SurveyCreatorModel, PropertyAddingEvent> = this.onShowingProperty;
from survey-library.
Related Issues (20)
- Logic for 'Added' Dynamic Matrix Rows HOT 1
- The Uncaught TypeError: value.setOwner is not a function exception is thrown when adding a new object to the survey.calculatedValues property HOT 1
- Serializer: an infinitive loop occurs at e.removePosFromObj
- Logic Tab - The Radiogroup | Clear button appears incorrectly HOT 1
- The `validate()` method ignores the `focusOnFirstError` parameter
- When using the numeric input mask, it's impossible to reset a field's value
- A "maximum call stack size exceeded" error is thrown when using carry forward
- Introduce an API to override a default renderer for all questions of a specific type
- Result shows wrong order of questions HOT 7
- Composite question types: Inherited localizable properties are duplicated in Survey Creator's Translation tab
- Conditional visibility animation is triggered at startup
- Dynamic Matrix with a File Upload column: The "Take Photo" button is unavailable for the second and subsequent rows
- Dropdown simultaneously displays predefined choices and auto-generated items HOT 1
- pReact implementation
- Multi-Select Matrix: A column's "Visible" checkbox is selected in Property Grid despite being set to `false` in the survey JSON schema
- When duplicated, a Rating Scale question applies the Dropdown display mode on the design surface
- Single matrix shows errors immediately on value change
- Auto-advance: A survey jumps over a page when using the Next button to navigate to the next page
- NextJS - Console Warnings when running the Form Library demo - Warning: Cannot update during an existing state transition (such as within `render`) HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from survey-library.