Skip to content

Instantly share code, notes, and snippets.

@tedkulp
Created December 30, 2008 14:05
Show Gist options
  • Save tedkulp/41627 to your computer and use it in GitHub Desktop.
Save tedkulp/41627 to your computer and use it in GitHub Desktop.
<?php
class TestController extends SilkControllerBase
{
function test_action($params)
{
$this->set('test', 'Controller Works!');
}
function test_ajax($params)
{
$this->show_layout = false;
$resp = new SilkAjax();
$resp->replace_html("#some_content", "New content says 'Hi!'");
$resp->replace("#some_content", "style", "color: red;");
$resp->insert("#some_content", " Append me, baby!");
$resp->insert("#some_content", "Prepend me, too. ", "prepend");
$resp->insert("#some_content", "<div id='after'>After</div>", "after");
$resp->insert("#some_content", "Before ", "before");
$resp->remove("#after");
return $resp->get_result();
}
}
?>
<html>
<head>
<title>{$title}</title>
{javascript file="lib/silk/jquery/jquery.js"}
{javascript file="lib/silk/jquery/jquery.color.js"}
{javascript file="lib/silk/jquery/jquery.silk.js"}
</head>
<body>
{$content}
</body>
</html>
<h1>Hello, world!</h1>
<p>The id is: {$params.id}</p>
<p>The controllers wants to say: {$test}</p>
{form remote='true' url='/silk/index.php/test/test_ajax'}
{textbox name="test" value="test" label="Test Me:"}
{select name="blah"}
{options items="0,blah,1,blah 2"}
{/select}
{submit}
{/form}
<div id="some_content">
Some Content
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment