Refresh a dynamic created fieldset - jquery-mobile

how can i refresh a dynamic created fieldset with checkbox?
I fill the checkbox with local loaded data. If i click a delete button and the local saved data is deleted so the fieldset with the checkbox should be refreshed.
I tried
$('#fieldset_item').trigger("create");
$('#item_List').trigger("create");
fieldset_item is the name of fieldset and item_List the name of the page.

$('#fieldset_item').trigger("create");
$('#item_List').trigger("create");
$('#fieldset_item').page();
$('#item_List').page();
This works great for me.

Related

Access list of multiple dropdowns using dictionary keyvalue pair. Selected value lost for Postback item

I am trying to display multiple dropdowns on post back on razor page in my ASP.NET MVC application inside a for loop using Dictionary<CountryCode, <selectList item with Country Selected>>.
Unfortunately, the selected value is lost and the dropdown is displayed with default selection.
enter image description here
Soultion found: The MVC Postback method required cleaning of ModalState as well. The Dynamically removed dropdowns were cleaned from our viewModel alone, cleaning it from the ModalState as well, solved the issue.
Because: Dropdownlistfor in the back end has a field called attempted value that was causing the dropdown selected value to get wiped out.
Thanks

How to append a empty row to a list/table which is bound to a OData(List Binding) in sapui5?

I have have a list/table which is bound to a entitySet from OData Model V2. I have a add(+) button on screen on clicking that button a empty row(s) need to be appended to the list/table. After that if I enter any data that should be saved into the backend on clicking of save button.
This is possible using JSONModel, but I want to use the OData model .
Regards,
Suman Kumar
It does work with two way data binding.
You can do that using odataModel createEntry method.
The createEntry expects a parameter, the path to your entitySet that you want to create (It should be something like XXXXset). Imagine the following:
1 - User clicks an "Add" button that renders a dialog Window with some fields and two buttons (save and cancel) for him to add his brand new entity.
2 - On the "open event" before you open the dialog, you create a new entity with the createEntry method. Its return gives you a context that you can bind to the dialog.
that.contextCursoIniciativaEmpregadoASerCriada = that.getView().getModel().createEntry('/CursoIniciativaEmpregadoSet');
that.fragmentCriacaoDadosInicEmpregado.bindElement(that.contextCursoIniciativaEmpregadoASerCriada.sPath);
that.fragmentCriacaoDadosInicEmpregado.open();
3 - The dialog pops up with the bind in place.
4 - The user fills the dialog with the entities properties
5 - The user clicks on the save button and you submit your changes

Add Quantity Selected to Cart Instead of Just Updating

I have an index page with items and a quantity select form.
The form works for create (a.k.a. first click). The problem is, if I click it again, it's just updating the cart instead of adding that quantity to the line_item. If this was my only problem I would be able to solve it myself.
The real problem is that I have another form that updates right before checkout. It looks like this:
I want this to be the master quantity control, so whatever goes in that form is what the quantity will be for update. But for the first images, I want that quantity to add to the quantity of the #line_item, so I can't just make a method that just adds the new and old quantities together, which is what I started doing until I realized I wouldn't be able to do that.
Do I need to make a new action in the controller?
What would be the work around for this?
Looking at your question
The problem is, if I click it again, it's just updating the cart instead of adding that quantity to the line_item
The problem is your submit button Add to Cart which takes it to the create action of your cart and hence creating a new item inside your cart
Do I need to make a new action in the controller?
My answer would be yes. You need to make a new action with post route request(to find that item) and then update its quantity inside that action.
What would be the work around for this?
If you look at your button or rather i should say form for creating a new item then it's the path or url part in your form which takes it to your method inside your controller. If you change its url then it will take it to your custom method.
Fix
All you need is some js magic to dynamically change the url or your form after a user has clicked on your Add to Cart button. Something like:
$(document).on("click","your_button_class",function(){
$(this).closest("your_form_class").attr("action","path_of_new_method");
});
You will also have to supply your items id by this form by adding a hidden field or something and then find that item inside controller method with that id to update its quantity.
Note: You need to call this js after your form is submitted and a new item is already created else it can trouble you.

sj:select tag in struts2-jquery plugin calls the JSON method again when the page gets submitted for a different action

This question is on Struts2 jquery plugin. While loading a JSP be default I am loading one dropdown list values and the second dropdown values are loaded based on selection of first dropdown. When the second dropdown value is selected an onChange event get executed and the page is getting refreshed. When the page is refreshing the First dropdown is getting called again! Is there anyway to avoid the second time execution of default loading of firstdropdown and also need to hold the selected values for both the submitted dropdown values of the JSP?
Note: First dropdown and second dropdowns are evaluated in SampleAction.java and onChange event executes LoadAction.java
Please let me know if you require further details!
Thanks
An option from the first dropdown is selected
Second dropdown is filled accordingly and then a value is selected
Instead of page-refresh, you can submit a form passing the values of both select tags
Now you get the selected values in your action and then you can show the same page but with prefilled values. This time when the page loads, the first select box by default shows the same previously selected value.
For the second select to show the previously selected value, you'll have to write some javascript code which will select the previously selected value.

I want to Dynamically Create Select list when i click a button by using struts2 tag?

I want to Dynamically Create Drop down list when i click a Button and the value selected in the Drop Down List should be inserted into the Database The Drop Down List should be in Struts2 Tag.
function addDropDown(parent){
var myselect = document.createElement("select");
myselect.setAttribute("name","someName");
myselect.onchange=function(){ submitvalue(this.value) };
theOption=document.createElement("OPTION");
theText=document.createTextNode("text gere1");
theOption.appendChild(theText);
theOption.setAttribute("value","value here1");
myselect.appendChild(theOption);
theOption=document.createElement("OPTION");
theText=document.createTextNode("text gere2");
theOption.appendChild(theText);
theOption.setAttribute("value","value gere2");
myselect.appendChild(theOption);
theOption=document.createElement("OPTION");
theText=document.createTextNode("text gere3");
theOption.appendChild(theText);
theOption.setAttribute("value","value gere3");
myselect.appendChild(theOption);
parent,appendChild(myselect);
}
call this function onClick of your button with some parent element(form or div) as argument.The function submitvalue() will be called on selection of any element of the dropdown, do your database submit action there(submit using ajax or whatever you are using as you have not mentioned it). I also noticed you have mentioned that the dropdown should be in struts2 tags, icouldnt wonder why as even the static struts2 tags get changed to html tags when executed

Resources