javascript - Script disables some components on my table -
as can seen in picture have have search on top right, in bottom right have amount of pages etc..
but add project here clicking "lägg till ny" , add project reason page end this: http://puu.sh/kkszz/387c71f487.png
as can seen table "breaks" search field gets removed , pages. same things happens when chose edit or delete project i've added.
this view:
<div id="tabs-current"> <div id="consultanttimes"> @{ html.renderaction("consulanttimes"); } </div> <a href="javascript:opendialog()" class="btn btn-primary"> lägg till ny </a> </div>
as can seen table partial view , here is:
<table class="table table-striped table-bordered table-hover" id="sample_1"> <thead> <tr> <th>projekt</th> <th>mitt datum</th> <th>%</th> <th>projektdatum</th> </tr> </thead> <tbody> @foreach (var project in viewdata["times"] list<consultantprojecttime>) { <tr> <td> <a href="javascript:opendialog2('@project.id','@project.fk_projectid','@project.startdate.toshortdatestring()','@project.enddate.toshortdatestring()','@project.pct');"> @project.project.projectname </a> </td> <td>@(project.startdate.toshortdatestring() + " - " + project.enddate.toshortdatestring())</td> <td>@(project.pct)%</td> <td> @if (project.project.startdate.hasvalue && project.project.enddate.hasvalue) { @(project.project.startdate.value.toshortdatestring() + " - " + project.project.enddate.value.toshortdatestring()) } </td> </tr> } </tbody>
and script run when choose add project:
$("#dialog").dialog({ bgiframe: true, autoopen: false, height: 220, width: 305, modal: true, buttons: { 'spara': function() { if (!validate()) { alert('procent måste vara mellan 0-100'); return false; } locstring = "@(url.action("index"))/update/?"; locstring += '&projectid=' + $('#projectlist').val(); locstring += '&startdate=' + $('#startdate').val(); locstring += '&enddate=' + $('#enddate').val(); locstring += '&pct=' + $('#pct').val(); var sid = $('#sid').text(); if (sid != "") { locstring += '&id=' + sid; //locstring = "/delete/" + sid; } //window.location = locstring; $.ajax({ type: "get", url: locstring, datatype: "html", success: function(data) { //alert(locstring); $('#dialog').dialog('close'); reloadtable(); } }); }, 'avbryt': function() { $(this).dialog('close'); }, 'ta bort': function() { var sid = $('#sid').text(); if (sid != "") { locstring = "@(url.action("index"))/delete/" + sid; //locstring += '&delete=true&id=' + sid; $.ajax({ type: "get", url: locstring, datatype: "html", success: function(data) { $('#dialog').dialog('close'); reloadtable(); } });
note, when happends have no errors in console.
found error not sure how solve it, it's reloadtable function:
function reloadtable() { if (navigator.appname == "microsoft internet explorer") { //alert('suck..'); window.location.reload(); } else { $.ajax({ type: "get", url: '@(url.action("consulanttimes"))', datatype: "html", success: function(data) { $('#dialog').dialog('close'); $('#consultanttimes').html(data); } }); } }
what doing replacing entire contents of #consultanttimes
, replacing data
variable. use $( "sample_1" ).replacewith(data);
instead, or maybe prepend or append.
Comments
Post a Comment