<div dir="ltr">Maybe there&#39;s a way to do this, but I have found myself recently wanting to be able to manipulate page regions on the basis of an action&#39;s result.<br><br>For example, I have an action that does a bunch of magic based upon the input. I have a page that shows a list of timers. These timers each belong to an entry, which groups a set of timers together. Each entry has a list of tasks associated with it that is displayed in a sidebar of each timer for that entry.<br>
<br>My magic action may have one of the following 5 manipulations that could happen. I&#39;ve listed the region manipulations I wish to do for each:<br><ol><li><b>Create a task.</b> If the action creates a new task, it will need to insert the task into zero or more lists (zero or more page regions depending on how many timers are currently being displayed on the page).</li>
<li><b>Comment on a task.</b> In this case, we don&#39;t need to refresh anything. All regions should remain unchanged.</li><li><b>Comment on a timer.</b> I&#39;d need to insert the new comment at the top of the comments list (a region) on the top-most timer.</li>
<li><b>Restart an entry.</b> I&#39;d need to insert a new timer (complete with a list of comments and tasks) at the top of the timers list.</li><li><b>Start a new entry.</b> This is exactly the same as (4), it just happens to represent a new, never before seen entry.</li>
</ol>I can do this pretty easily by just refreshing the whole page, but I&#39;d rather not. The page can get pretty long by the end of a day and the point of using ajax is so that I don&#39;t have to refresh the whole page.<br>
<br>What I feel like I&#39;d like to do is something like this from the action:<br><br># on create a task<br>$self-&gt;result-&gt;update_page({<br>&nbsp;&nbsp;&nbsp; region =&gt; &#39;entry_list-entry_14-task_list&#39;,<br>&nbsp;&nbsp;&nbsp; prepend =&gt; &#39;/journal/task&#39;,<br>
&nbsp;&nbsp;&nbsp; arguments =&gt; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; task_id =&gt; 103,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; format =&gt; &#39;journal&#39;,<br>&nbsp;&nbsp;&nbsp; },<br>});<br><br># on comment on a task.... nothing<br><br># on comment on a timer<br>$self-&gt;result-&gt;update_page({<br>
&nbsp;&nbsp;&nbsp; region =&gt; &#39;entry_list-entry_14-comment_list&#39;,<br>&nbsp;&nbsp;&nbsp; prepend =&gt; &#39;/journal/view_comment&#39;,<br>&nbsp;&nbsp;&nbsp; arguments =&gt; { comment_id =&gt; 7813 },<br>});<br><br># on restart an entry<br>$self-&gt;result-&gt;update_page({<br>
&nbsp;&nbsp;&nbsp; region =&gt; &#39;entry_list&#39;,<br>&nbsp;&nbsp;&nbsp; prepend =&gt; &#39;/journal/view_timer&#39;,<br>&nbsp;&nbsp;&nbsp; arguments =&gt; { timer_id =&gt; 155 },<br>});<br><br># on start a new entry<br># same as above<br><br>Essentially, I&#39;d like to change the onclick actions in the response from the action itself rather than having to foreknow them during at click time.<br>
<br>The other solution I&#39;ve come up with (and quite possibly the one I use for now) is to include 5 different buttons that each do these things. Then, present the button that does the right thing as soon as we have enough input to make that judgment. I do that to some extent now by having an extra ajax request that changes the name of the button to something that hints at what&#39;s going on (1=Taskinate, 2=Comment, 3=Post, 4=Restart, 5=Start), but there are a couple places where I&#39;m going to have to handle that delicately to make sure it DWIMs.<br>
<br>I&#39;m open to doing this anyway that works reasonably well and will to commit smallish sized patches to help at thsi time, but I don&#39;t have much time to spare at the moment for anything moderate to largish.<br><br>
Any suggestions?<br><br>Cheers,<br>Sterling<br></div>