I have 2 dropdown boxes. one dropdown box sets another dropdown box. The second dropdown box's value is used to populate a Date. For whatever reason the value that is used to set the date is always the previous value in the 2nd drop down box. I want to get the latest value not the earlier value.
Note this is razor and they are partial classes.
I've tried using a .when done (commented out below).
I even tried calling the SetCurrentQualDate inside the load
It always gets the preious value and nothing seems to work
$("#requalifty-wps-dd").change(function () {
$("#requalify-process-dd").load('#Url.Action("GetProcessName_Requalify", "Home")'+ "?selectedWPSID=" + $("#requalifty-wps-dd").val());//,SetCurrentQualDate());
$('#requalify-process-dd').prop('disabled', false);
//$.when(loading != null).done(SetCurrentQualDate());
//$.when(loading).done(SetCurrentQualDate());
//SetCurrentQualDate().after(callBack($("#requalifty-wps-dd").val()));
});
//.done(SetCurrentQualDate());
$("#requalify-process-dd :selected").change(function () {
SetCurrentQualDate();
});
I want to get the latest value from the load
I think you're looking on something that is async, using get instead of load should do the trick:
$("#requalifty-wps-dd").change(function () {
$.get('#Url.Action("GetProcessName_Requalify", "Home")' + "?selectedWPSID=" + $("#requalifty-wps-dd").val(), function(data) {
$('#requalify-process-dd').html(data).prop('disabled', false);
SetCurrentQualDate()
});
$('#requalify-process-dd').prop('disabled', false);
});
Related
I have GridView with data which works perfectly fine and everything loads correctly. I need to extract data from one column using button but the function will always return undefined even it's loaded correctly.
In same .cshtml file with grid and button I have this "simple" script with 2 functions:
<script id="dxss_1610925110" type="text/javascript">
function ShowValue() {
gridViewINS.GetRowValues(gridViewINS.GetFocusedRowIndex(), "Insolvency.FileNumber", gridViewINSOnGetRowValues());
}
function gridViewINSOnGetRowValues(value) {
alert(value);
}
</script>
Now when I click the button two alerts pop up. One is undefined. The second is literally snippet of my code which has the value in it which I need. So it can get somehow the data but why not directly to value property? I can't find what I am doing wrong. Any help will be appreciated.
I think you need to remove the parentheses () from gridViewINSOnGetRowValues().
Like so:
gridViewINS.GetRowValues(gridViewINS.GetFocusedRowIndex(), "Insolvency.FileNumber", gridViewINSOnGetRowValues);
I'm using select2 on a project, and is working as it should, initiating the select2 using:
$(function() {
$(".elegible").select2();
});
The issue comes in when I'm trying to call de function to elements loaded by JQuery, I don't know how to call that function. I've tried "on" but it does not load the selects with the select2. The only thing I found is this:
$(document).ajaxComplete(function(e, xhr, settings){
$(".elegible").select2();
});
But this calls that function every time an ajax call is completed, even in those cases when I'm not needing the select2. My question is: How can I call the select to on elements loaded later? Is the method that I'm using right now valid? Can I improve that?
Thanks!
Adding Info:
I call the new content by getting it from another page - which loads the select - using ajax:
$.get('detalle_miembro/' + this.id)
.done(function(result) {
$('#detalle_miembro').html(result);
});
And placing it, in a div: <div id="detalle_miembro"></div>
Here is how you can call select on just the new content added:
$.get('detalle_miembro/' + this.id).done(function(result) {
$('#detalle_miembro').html(result).find(".elegible").select2();
});
I am basically trying to get values with an ajax request based on a specific id. I then would like to load the json List returned, and load it into a jstl foreach loop. This is my code for the ajax GET request:
$(this).on("click", ".edit_sighting", function(){
var username = +$(".edit_sighting").val();
$.get("${pageContext.request.contextPath}/getSighting/" + username, function(sightings) {
});
});
My Button that gets pressed to load these values: So when this is instantiated, I want to load all the sightings that user has into a modal.
<button class="edit_sighting" value="${sighting.username}">Edit Sighting</button>
I want the returned 'sightings' to go into a c:foreach loop to show if the user has more than 1 sighting.
<c:forEach var="" items="${?}">
</c:forEach>
I dont know how to set the jQuery value returned into the 'var' section?
Thanks
Try this:
$(this).on('click', '.edit_sighting', function() {
$.get('${pageContext.request.contextPath}/getSighting/' + $('.edit_sighting').val(), function(sightings) {
$('c\\:forEach').attr('var', sightings);
});
});
Also, why are you using $(this) as a selector when binding the click event?
I've created some hidden drop-down fields that I'm attempting to keep hidden until appropriately selected.
I'm trying to do this with mootools - I've put in 'alerts' so that I can see the variables getting passed along at each step.
The first hidden dropdown shows appropriately and the value displays accordingly, but when a value is selected from the 2nd dropdown the value is 'undefined' and the 3rd dropdown does not display.
I've been looking it over time and time again but cannot figure out why this won't work. Any advice would be greatly appreciated. I'm new to mootools & Javascript so it may be a simple fix I'm just not seeing.
You can view the JSFiddle for this - it contains all the html/javascript.
This works. Instead of relying on this, I changed it to use the passed Event object, then got the target from that.
window.addEvent('domready', function() {
$('numberStyle').addEvent('change', function() {
var targ = $(this.get('value'));
$$('.sub-1').setStyle('display', 'none');
targ.setStyle('display', 'block');
alert('TargID = ' + targ.id);
targ.addEvent('change', function(evt) {
var targID1 = $(evt.target).get('value');
alert('The value is of sub-1 is ' + targID1);
$$('.sub-2').setStyle('display', 'none');
$(targID1).setStyle('display', 'block');
});
});
});
I am using the jqGrid plug-in and at one point I need to refresh the grid and set the selected row to match the record that I am showing in detail on another section of the page. I have the following code but it does not work:
$("#AllActions").trigger("reloadGrid").setSelection(selectedRow);
The selectedRow parameter comes from an event handler that gets called when the data is changed and the grid needs to be updated.
I'm pretty sure that the problem is that the grid is not loaded when the selection is being set, because if I put a call to alert() between the calls to trigger() and setSelection(), it works.
I would be grateful for any advice.
[Edit]Looks like jqGrid's setSelect does not work after reloadGrid is related but did not get resolved.[/Edit]
Firts of all you should save rowid of the old selection in a variable, then call $("#AllActions").trigger("reloadGrid") and inside of loadComplete event handler set selection with respect of $("#AllActions").setSelection(rowid).
Don't forget to set option scrollrows:true of the jqGrid, to be sure that the selected row will be visible.
Try this, I did it, and it works.
setTimeout("$('#grid').jqGrid('setSelection','"+id+"')", 1000);
and of course in the config of the master grid.. you can use somthing like this
onSelectRow: function(ids) {
if(ids == null) {
ids=0;
if($("#grid-detail").jqGrid('getGridParam','records') >0 ) {
$("#grid-detail").jqGrid('setGridParam',{url:"server.php?&grid=1&oper=get_records&id=&id="+ids,page:1});
$("#grid-detail").jqGrid().trigger('reloadGrid');
}
} else {
var arr = jQuery("#list-maestro").getRowData( ids );
var id = arr.id;
$("#grid-detail").jqGrid('setGridParam',{url:"server.php?&grid=1&oper=get_records&id="+id,page:1});
$("#grid-detail").jqGrid().trigger('reloadGrid');
}
}