I am working on a meteorjs application in which we have a form and some inputs get rendered based on the values of the session variable which is set on the change of another input we have applied a jquery plugin to the form that manipulates the inputs of the form but the plugin does not affect on the dynamically rendered input controls.If anybody has any idea please help me.
The problem is as follows:
there is a service select box and when user changes the values of the service we will set a session variable true and in the template if this session variable is true we will show another select for sub category and we have already applied the plugin on the form with onrendred but the plugin works for the services salect but does not affect sub category select.
Related
I trying to create a custom property editor for Umbraco 7 that talks to an external web service, retrieves some data then populates a number fields in the form with the data it's retrieved. I've tried doing this with the following simple code:
$("#textbox_id").val("new value");
This does indeed populate the correct field with the correct data. However if I save and reload the form the data has not been updated and value returns to it's original value.
Any suggestions?
The problem is that you are using jQuery to update the input field directly in the DOM. The backoffice of Umbraco is completely wired up with an angular model and this model is not notified of the change in this input field when you are not actually typing in the field.
You can however trigger the input even on the form fields after updating the value of the field, which will ensure that angular gets notified of the change and it will update its model.
Something like this should get the job done and the change should now be included when you hit the save button:
$("#textbox_id").val("new value").trigger("input");
I'm planing to create generic form created dynamically with JSON data from server.
Assume a ng form, using ng repeat we populating dynamic form, based on the first set of JSON.
If the form has drop-down or radio elements there should be another call to get subset elements (textbox, radio) to populate under the parent drop down or radio.
If drop-down changes, sub form should be added under the parent drop down.
There is no workflow using those data. Only CRUD Operations are performed.
I'm planing this to do generically from angular controller till db design level.
How the db/service design should be for making Json for parent set?
How to link the parent and sub set even sub's subset?
How to save the data and do edit operation?
Also is it better idea to save data as Json in db column?
I am not sure if I understood your question but if you have an option to display a form from a set of forms, you can just create templates of those forms and display them on the dropdown select.
If it is a generic form template then I guess you only have to change the labels and the form names in those html templates. You can bind the values to the same model names to ng-model in the controller.
DB design depends on the nature of data you have, which you have not mentioned, so its tough to answer.
'JSON data' is the payload passed through your REST services. That has to do with how you design your response data. If its just form-templates details for the form suggested you've selected in the dropdown, then you can just pass the label names and data types for those fields.
So there will be 2 services.
1. A GET to get the Form template labels and field definitions.
2. A POST to submit the form.
Keep in mind that all these forms are defined at the beginning and not created on the fly. i.e you cannot create a new form-template on the fly.
I'm using Materialized CSS and it works very well for me. However when I added more dynamic behaviour to my app, for example when I'm pre-populating form with values and appending them to the layout, here is the photo of that:
That happens only when I preset the value to form on/prior to page load (because my form html is generated by server side).
However if I were to click into the quantity field then quantity would go back to its place and it would stay there.
How do I make it so that it stays up even when I pre-populate the form value? Is there a class I need to add to it (label or input) or JavaScript or something that I can put out there.
If you want to pre-fill text inputs, use Materialize.updateTextField(); as the docs says
I am using laravel framework in PHP.
In a view I have a project dropdown where user can select a particular project and the project is remain selected untill he doesn't change the project againg by selecting the dropdown.
I did this by having a session 'project', whenever user chnages the dropdown option the session is set to the value of selected project. I have done this but my issue is that i want to show the selected project name in the projects dropdown.
For this I think javascript will be a good solution , I have the following code-
$("#projectlist").find( option[value="{{Session::get('project')}}"]).attr("selected", "true");
where 'projectlist' is the id of dropdown and i want to set the selected option equal to the value stored in the session 'project'.
But I am not getting the selected option as per the session value.
Since you're using blade to achieve this, javascript is not what you'd want to use. For the project dropdown, just use the laravel Form library and provide it there.
{{ Form::select('projects', $projectList, Session::get('project')) }}
This way, it'll select whatever the value is, and you'll see that as the name. There's absolutely no need what so ever to use javascript, unless you're loading the currently selected project value in via ajax.
You will want to use val() for this to set the value. This is also assuming your javascript is being placed inside a *.blade.php file.
$("#projectlist").val({{Session::get('project')}});
I'm building an App that is heavy on jQuery. Most of it I can handle without the use of JS and still have a functioning site, however there is one bit that is eluding me. (note, I'm using ASP.NET MVC but that shouldn't matter in this instance)
I have an input field that is making great use of jQuery-UI AutoComplete. The behavior is very simple. The user is asked to input their City, but is given an AutoComplete list of valid cities. If the city is invalid, the server side validation fires and tells them to try again.
If they do select a valid city, the jQuery method updates a hidden field that contains the CityID of the selected city. This is working phenomenally well, and I really like the performance.
Here's where the problem enters. If JS is not available in the browser, the ID field is not updated, and hence the DB is not updated. I am not using the AutoComplete input on the server side at all, just the ID field. What would be a good solution to circumvent this issue?
Default to a select element containing the cities as options and id's as values, and change it to the autocomplete field with the script on page load.
If for some reason sje397's answer doesn't work for you (it's an elegant solution, unless the city auto-select is based on some other field on-screen, such as a zip code or state), simply POST both fields. When evaluating the POSTed data, if the CITY text box has data, and the hidden field does not, then evaluate the entered city using the same validation method used by the jquery callback. If the hidden field has data, you assume that javascript is enabled and use your current logic.
Several options:
1 - Serve HTML initially that shows the "hidden" input, and doesn't include the "autocomplete" one. When JS loads, have a function edit the DOM to your current situation.
2 - Have the form default to send the "autocomplete" data to the server. Use javascript to edit the "send" function to have it switch to the "hidden" input.
Get the page to by default to send the input of the user over the intertubes to your server, if javascript is enabled, change it so it only sends the ID over instead (using javascript obviously).