invalidace komponenty po mazani ajaxem

Upozornění: Tohle vlákno je hodně staré a informace nemusí být platné pro současné Nette.
Muhahe
Člen | 79
+
0
-

Zdravim,

mam komponentu, ktera obsahuje tabulku, ve ktere ajaxem mazu radek. Po uspesnem ajaxovem pozadavku bych rad aby se komponenta invalidovala a obnovila.

Zde mam javascript pro mazani ajaxem

<script>
function showProjectDeleteConfirm(projectName,projectId,element,tableId){
    var projectLink = document.getElementById("deleteProjectDialog").getAttribute("data-link");

    $("#deleteProjectDialog").dialog({
        resizable: false,
        height: 140,
        modal: true,
        title: "Delete project?",
        open: function(){
          var innerText = "Project " + projectName + " will be deleted.";
          $(this).html(innerText);
        },
        buttons:{
            "Confirm" : function(){

                $.post(projectLink, { id_project_delete: projectId });
                $(this).dialog("close");

                //datatableRemoveRow($(element).parent().parent(),tableId)
            },
            Cancel: function(){
                $(this).dialog("close");
            }
        }
    })
    //console.log();
}
</script>

zde volany actionDeleteProject kde se snazim invalidovat komponentu projectList

<?php

    public function actionDeleteProject() {
        $id = $this->getHttpRequest()->getPost('id_project_delete');
        $this->projectsRepository->deleteProject($id);
        $this->redrawControl('projectList');


    }

 ?>


v latte vykreslene stranky.

<?php

{block content}
<div id ="projectsBody">
    <h1>Projects</h1>
    <div id="projects">
      <!--  <div id="gantt"></div> -->
        {snippet projectList}
            {control projectList}
        {/snippet}
        <div id="gantt"></div>
    </div>

    <div id="newProjectFormContainer">
        {control newProjectForm}
    </div>

    <div id="newTaskFormContainer">
        {control newTaskForm}
    </div>
</div>
{/block}
?>

Ve firebugu mam chybu 500 Internal server error, o chybejici sablone
exception ‚Nette\Application\BadRequestException‘ with message ‚Page not found. Missing template '…\nette
\20140708_TRW_nette\app\templates\Projects\deleteProject.latte‘.' in C:\nette\20140708_TRW_nette\vendor
\nette\application\src\Application\UI\Presenter.php:700

Pokud pridam na konec action $this->terminate(); chyba zmizi, ale obnoveni komponenty se neprovede. Nevidite nekdo prosim kde by mohl byt problem?

Editoval Muhahe (25. 5. 2015 19:45)

David Matějka
Moderator | 6445
+
0
-
  1. pro mazani nepouzivej akci, ale signal. Tim, ze zmenis akci, se nevykresli ta sablona a tudiz nedojde k prekresleni snippetu
  2. ten signal nejlepe jeste zabezpec pomoci nextras/secured-links
Muhahe
Člen | 79
+
0
-

Diky moc za radu, zkusil jsem to premontovat signal se posle, polozka se smaze, ale narazim na chybovou hlasku jQuery.nette.updateSnippet is not a function

takto mam handler

<?php

    public function handleDeleteProject(){
        $id = $this->getHttpRequest()->getPost('id_project_delete');
        $this->projectsRepository->deleteProject($id);
        $this->redrawControl('projectList');
    }

?>

takto jsem zmenil ajax

<script>

function showProjectDeleteConfirm(projectName,projectId,element,tableId){
    var projectLink = document.getElementById("deleteProjectDialog").getAttribute("data-link");

    $("#deleteProjectDialog").dialog({
        resizable: false,
        height: 140,
        modal: true,
        title: "Delete project?",
        open: function(){
          var innerText = "Project " + projectName + " will be deleted.";
          $(this).html(innerText);
        },
        buttons:{
            "Confirm" : function(){
                $.ajax({
                    type: 'POST',
                    url: projectLink,
                    data: {'id_project_delete':projectId},
                    error: function(xhr, err){

                        console.log("ajax error");
                        console.log("ready state: " + xhr.readyState + " status " + xhr.status );
                        console.log("response text: "+xhr.responseText);
                    }

                });
                //$.post(projectLink, { id_project_delete: projectId });
                $(this).dialog("close");

                //datatableRemoveRow($(element).parent().parent(),tableId)
            },
            Cancel: function(){
                $(this).dialog("close");
            }
        }
    })
    //console.log();
}

</script>

includuju jquery.nette.js a nette.ajax.js

tak jsem odstranil nette.ajax.js a zda se ze to funguje. Nevedel by nekdo proc?

Editoval Muhahe (26. 5. 2015 19:43)