Hi all,
I might be missing something here, but it's confusing to see that the with: message sometimes expects a string, and sometimes a block, depending on which tag/brush the message is sent to.
For example, html script with: expects a string, while html div with: expects a block.
What's the rationale behind this?
Thanks,
Hans
That is not correct.
Look at the implemenation in WATagBrush. with: 'asdasd' and with: [] and: with: anyKindOfObject is basically available for all tags!
The argument of #with: is rendered using double dispatching, therefore any object can be passed as argument.
br Gerhard
In that case, how come:
html script with: [html text: 'testing']
renders:
<script type="text/javascript">/*<![CDATA[*/[] in STAAMenuComponent>>renderContentOn: {[html text: 'testing']}/*]]>*/</script>
while html script with: 'testing'
renders:
<script type="text/javascript">/*<![CDATA[*/testing/*]]>*/</script>
? This is what I mean by the script tag expecting a string. Sure, you can pass it a block, but the block won't be evaluated as I would like it to be.
Or did I misunderstand you?
Thanks,
Hans
On Wednesday 23 July 2008 13:53:00 Gerhard Obermann wrote:
That is not correct.
Look at the implemenation in WATagBrush. with: 'asdasd' and with: [] and: with: anyKindOfObject is basically available for all tags!
The argument of #with: is rendered using double dispatching, therefore any object can be passed as argument.
br Gerhard
Sorry i am reading too fast. script: is an exception because javascript is only evaluated on the client. Obviously you cant pass a block to javascript.
Just look at WAScriptTag!
self document nextPutAll: aString displayString
It only takes the displayString of the argument.
br Gerhard
On Wed, Jul 23, 2008 at 2:00 PM, SainTiss saintiss@gmx.net wrote:
In that case, how come:
html script with: [html text: 'testing']
renders:
<script type="text/javascript">/*<![CDATA[*/[] in STAAMenuComponent>>renderContentOn: {[html text: 'testing']}/*]]>*/</script>
while html script with: 'testing'
renders:
<script type="text/javascript">/*<![CDATA[*/testing/*]]>*/</script>
? This is what I mean by the script tag expecting a string. Sure, you can pass it a block, but the block won't be evaluated as I would like it to be.
Or did I misunderstand you?
Thanks,
Hans
On Wednesday 23 July 2008 13:53:00 Gerhard Obermann wrote:
That is not correct.
Look at the implemenation in WATagBrush. with: 'asdasd' and with: [] and: with: anyKindOfObject is basically available for all tags!
The argument of #with: is rendered using double dispatching, therefore any object can be passed as argument.
br Gerhard
-- A liberal is a person whose interests aren't at stake at the moment -- Willis Player
Hans Schippers Research Assistant of the Research Foundation - Flanders (FWO - Vlaanderen) http://www.win.ua.ac.be/~hschipp/ http://www.win.ua.ac.be/%7Ehschipp/ Formal Techniques in Software Engineering (FoTS) University of Antwerp Middelheimlaan 1 2020 Antwerpen - Belgium Phone: +32 3 265 37 88 Fax: +32 3 265 37 77 _______________________________________________ seaside mailing list seaside@lists.squeakfoundation.org http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Ok, I see...
The point is that I don't really want to pass a block to javascript, as, indeed, that wouldn't make sense: I just want to embed some *html string* in javascript, like this:
<script> myHtmlString='<a href="internalSeasideLink">test</a>' </script>
So the whole point is that I want to use "html anchor" to generate the correct html string for me, since there seems to be no other way to figure out the "internalSeasideLink" in my example, which I need if I want the link to execute a callback
Hans
On Wednesday 23 July 2008 14:23:58 Gerhard Obermann wrote:
Sorry i am reading too fast. script: is an exception because javascript is only evaluated on the client. Obviously you cant pass a block to javascript.
Just look at WAScriptTag!
self document nextPutAll: aString displayString
It only takes the displayString of the argument.
br Gerhard
On Wed, Jul 23, 2008 at 2:00 PM, SainTiss saintiss@gmx.net wrote:
In that case, how come:
html script with: [html text: 'testing']
renders:
<script type="text/javascript">/*<![CDATA[*/[] in STAAMenuComponent>>renderContentOn: {[html text: 'testing']}/*]]>*/</script>
while html script with: 'testing'
renders:
<script type="text/javascript">/*<![CDATA[*/testing/*]]>*/</script>
? This is what I mean by the script tag expecting a string. Sure, you can pass it a block, but the block won't be evaluated as I would like it to be.
Or did I misunderstand you?
Thanks,
Hans
On Wednesday 23 July 2008 13:53:00 Gerhard Obermann wrote:
That is not correct.
Look at the implemenation in WATagBrush. with: 'asdasd' and with: [] and: with: anyKindOfObject is basically available for all tags!
The argument of #with: is rendered using double dispatching, therefore any object can be passed as argument.
br Gerhard
-- A liberal is a person whose interests aren't at stake at the moment -- Willis Player
Hans Schippers Research Assistant of the Research Foundation - Flanders (FWO - Vlaanderen) http://www.win.ua.ac.be/~hschipp/ http://www.win.ua.ac.be/%7Ehschipp/ Formal Techniques in Software Engineering (FoTS) University of Antwerp Middelheimlaan 1 2020 Antwerpen - Belgium Phone: +32 3 265 37 88 Fax: +32 3 265 37 77 _______________________________________________ seaside mailing list seaside@lists.squeakfoundation.org http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Try
url := html urlForAction: [ foo ]
I haven't been reading the thread closely enough to know whether this is the best solution to doing what you want with javascript. But it will get you a URL that runs your block.
Julian
On Wed, Jul 23, 2008 at 9:31 PM, SainTiss saintiss@gmx.net wrote:
Ok, I see...
The point is that I don't really want to pass a block to javascript, as, indeed, that wouldn't make sense: I just want to embed some *html string* in javascript, like this:
<script> myHtmlString='<a href="internalSeasideLink">test</a>' </script>
So the whole point is that I want to use "html anchor" to generate the correct html string for me, since there seems to be no other way to figure out the "internalSeasideLink" in my example, which I need if I want the link to execute a callback
Hans
On Wednesday 23 July 2008 14:23:58 Gerhard Obermann wrote:
Sorry i am reading too fast. script: is an exception because javascript is only evaluated on the client. Obviously you cant pass a block to javascript.
Just look at WAScriptTag!
self document nextPutAll: aString displayString
It only takes the displayString of the argument.
br Gerhard
On Wed, Jul 23, 2008 at 2:00 PM, SainTiss saintiss@gmx.net wrote:
In that case, how come:
html script with: [html text: 'testing']
renders:
<script type="text/javascript">/*<![CDATA[*/[] in STAAMenuComponent>>renderContentOn: {[html text: 'testing']}/*]]>*/</script>
while html script with: 'testing'
renders:
<script type="text/javascript">/*<![CDATA[*/testing/*]]>*/</script>
? This is what I mean by the script tag expecting a string. Sure, you can pass it a block, but the block won't be evaluated as I would like it to be.
Or did I misunderstand you?
Thanks,
Hans
On Wednesday 23 July 2008 13:53:00 Gerhard Obermann wrote:
That is not correct.
Look at the implemenation in WATagBrush. with: 'asdasd' and with: [] and: with: anyKindOfObject is basically available for all tags!
The argument of #with: is rendered using double dispatching, therefore any object can be passed as argument.
br Gerhard
-- A liberal is a person whose interests aren't at stake at the moment -- Willis Player
Hans Schippers Research Assistant of the Research Foundation - Flanders (FWO - Vlaanderen) http://www.win.ua.ac.be/~hschipp/ http://www.win.ua.ac.be/%7Ehschipp/ Formal Techniques in Software Engineering (FoTS) University of Antwerp Middelheimlaan 1 2020 Antwerpen - Belgium Phone: +32 3 265 37 88 Fax: +32 3 265 37 77 _______________________________________________ seaside mailing list seaside@lists.squeakfoundation.org http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
-- A liberal is a person whose interests aren't at stake at the moment -- Willis Player
Hans Schippers Research Assistant of the Research Foundation - Flanders (FWO - Vlaanderen) http://www.win.ua.ac.be/~hschipp/ Formal Techniques in Software Engineering (FoTS) University of Antwerp Middelheimlaan 1 2020 Antwerpen - Belgium Phone: +32 3 265 37 88 Fax: +32 3 265 37 77 _______________________________________________ seaside mailing list seaside@lists.squeakfoundation.org http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Perfect!
AND it will rerender the page :)
Thanks,
Hans
On Wednesday 23 July 2008 16:45:28 Julian Fitzell wrote:
Try
url := html urlForAction: [ foo ]
I haven't been reading the thread closely enough to know whether this is the best solution to doing what you want with javascript. But it will get you a URL that runs your block.
Julian
On Wed, Jul 23, 2008 at 9:31 PM, SainTiss saintiss@gmx.net wrote:
Ok, I see...
The point is that I don't really want to pass a block to javascript, as, indeed, that wouldn't make sense: I just want to embed some *html string* in javascript, like this:
<script> myHtmlString='<a href="internalSeasideLink">test</a>' </script>
So the whole point is that I want to use "html anchor" to generate the correct html string for me, since there seems to be no other way to figure out the "internalSeasideLink" in my example, which I need if I want the link to execute a callback
Hans
On Wednesday 23 July 2008 14:23:58 Gerhard Obermann wrote:
Sorry i am reading too fast. script: is an exception because javascript is only evaluated on the client. Obviously you cant pass a block to javascript.
Just look at WAScriptTag!
self document nextPutAll: aString displayString
It only takes the displayString of the argument.
br Gerhard
On Wed, Jul 23, 2008 at 2:00 PM, SainTiss saintiss@gmx.net wrote:
In that case, how come:
html script with: [html text: 'testing']
renders:
<script type="text/javascript">/*<![CDATA[*/[] in STAAMenuComponent>>renderContentOn: {[html text: 'testing']}/*]]>*/</script>
while html script with: 'testing'
renders:
<script type="text/javascript">/*<![CDATA[*/testing/*]]>*/</script>
? This is what I mean by the script tag expecting a string. Sure, you can pass it a block, but the block won't be evaluated as I would like it to be.
Or did I misunderstand you?
Thanks,
Hans
On Wednesday 23 July 2008 13:53:00 Gerhard Obermann wrote:
That is not correct.
Look at the implemenation in WATagBrush. with: 'asdasd' and with: [] and: with: anyKindOfObject is basically available for all tags!
The argument of #with: is rendered using double dispatching, therefore any object can be passed as argument.
br Gerhard
-- A liberal is a person whose interests aren't at stake at the moment -- Willis Player
Hans Schippers Research Assistant of the Research Foundation - Flanders (FWO - Vlaanderen) http://www.win.ua.ac.be/~hschipp/ http://www.win.ua.ac.be/%7Ehschipp/ Formal Techniques in Software Engineering (FoTS) University of Antwerp Middelheimlaan 1 2020 Antwerpen - Belgium Phone: +32 3 265 37 88 Fax: +32 3 265 37 77 _______________________________________________ seaside mailing list seaside@lists.squeakfoundation.org http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
-- A liberal is a person whose interests aren't at stake at the moment -- Willis Player
Hans Schippers Research Assistant of the Research Foundation - Flanders (FWO - Vlaanderen) http://www.win.ua.ac.be/~hschipp/ Formal Techniques in Software Engineering (FoTS) University of Antwerp Middelheimlaan 1 2020 Antwerpen - Belgium Phone: +32 3 265 37 88 Fax: +32 3 265 37 77 _______________________________________________ seaside mailing list seaside@lists.squeakfoundation.org http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
seaside mailing list seaside@lists.squeakfoundation.org http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
"SainTiss" saintiss@gmx.net wrote in message news:200807231656.43664.saintiss@gmx.net...
Perfect!
AND it will rerender the page :)
For an Ajax version, you can also insert an (html updater...) printString into your javascript. #updater will replace a target element in browser with the callback rendering from the server; #request will just make a server request.
e.g. renderContentOn: html html script: 'function showCell(cellid) {', ((html updater id: 'theTargetElement';
"1 primary callback on server, including re-rendering onto :r" callback: [:r | self renderResultOn: r];
"0 or more secondary callbacks with client-side /value/ e.g. to pass back other client-side values" callback: [:v | self recordClientValue: v] "value: turns into JS for client to pass back" value: (SUStream new nextPutAll: 'cellid'))) printString, '}'.
- Sophie
Say I have a page that has entry fields in a form (with a submit button) but also on the page is one or more anchors. The anchors are not really intended to abandon the page, but just to update the display in some way (like the column names in a WATableReport that sort the rows) or do a call/answer to collect some more data for the current page. The problem is that if the user clicks on a link the data is the form is not processed. I understand why it works this way, but from a usability point of view it is unexpected. Is there some way (JavaScript?) of setting some trigger to trap navigation away from the page check for any modified fields and take some action (like an auto- submit or a confirm dialog)?
James Foster
Hi James,
you might try to add a onClick: script to it, that triggers the forms. This will submit the forms and should still call the callback. though i'm not 100% sure if the submit button's callback will be executed as well, but i somehow doubt it. just try it out.
Good luck Karsten
James Foster wrote:
Say I have a page that has entry fields in a form (with a submit button) but also on the page is one or more anchors. The anchors are not really intended to abandon the page, but just to update the display in some way (like the column names in a WATableReport that sort the rows) or do a call/answer to collect some more data for the current page. The problem is that if the user clicks on a link the data is the form is not processed. I understand why it works this way, but from a usability point of view it is unexpected. Is there some way (JavaScript?) of setting some trigger to trap navigation away from the page check for any modified fields and take some action (like an auto-submit or a confirm dialog)?
James Foster _______________________________________________ seaside mailing list seaside@lists.squeakfoundation.org http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
James Foster wrote:
Say I have a page that has entry fields in a form (with a submit button) but also on the page is one or more anchors. The anchors are not really intended to abandon the page, but just to update the display in some way (like the column names in a WATableReport that sort the rows) or do a call/answer to collect some more data for the current page. The problem is that if the user clicks on a link the data is the form is not processed. I understand why it works this way, but from a usability point of view it is unexpected. Is there some way (JavaScript?) of setting some trigger to trap navigation away from the page check for any modified fields and take some action (like an auto-submit or a confirm dialog)?
James Foster
In case anyone is interested, I came up with the following JavaScript (with Scriptaculous) code that seems to do what I want in a generalized fashion. Any comments are welcome...
window.onbeforeunload = confirmExit;
var needToConfirm = true; var inputElements = $$(''form input''); var initialValues = currentValues();
function currentValues() { var values = []; inputElements.each( function(each) { values.push(each.getValue()); } ); return values; }
function confirmExit() { if (needToConfirm) { var values = currentValues(); for (var i = 0; i < values.length; i++) { if (initialValues[i] !== values[i]) return "Unsaved changes have been made to form input elements on this page."; } } }
$$(''form button.submit'').each( function(each) { each.onclick = noNeedToConfirm; } );
function noNeedToConfirm() { needToConfirm = false; }
The problem is that if the user clicks on a link the data is the form is not processed. I understand why it works this way, but from a usability point of view it is unexpected. Is there some way (JavaScript?) of setting some trigger to trap navigation away from the page check for any modified fields and take some action (like an auto-submit or a confirm dialog)?
Not sure if it applies for your case, but with Scriptaculous you can have something like:
html submitButton onClick: (html request "updater if you want a request plus an update triggerForm: 'yourFormId' "triggerFormElement if you only want a field... except multiples choices) callback: [:value | ...]) with: 'name'
if updater, you have a block with a renderer
...onClick: (html updater id: 'anidToBerendered'; triggerFormElement: 'anId'; callback: [ :render | self renderThisBlock] ...
hth
Cédrick
James Foster _______________________________________________ seaside mailing list seaside@lists.squeakfoundation.org http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
2008/7/23 SainTiss saintiss@gmx.net:
Hi all,
I might be missing something here, but it's confusing to see that the with: message sometimes expects a string, and sometimes a block, depending on which tag/brush the message is sent to.
For example, html script with: expects a string, while html div with: expects a block.
What's the rationale behind this?
That's tricky, like for most tricky things the answer is "because that's the way HTML is". The main issue that the contents of a <script> or <style> have different semantics than the contents of any other elment. We must not html entity escape the contents of a <script> or <style> element. As an example the contents of:
<script>&</script> <div>&</div>
are very different (in HTML only).
Also note that there are two different classes for <script>, WAScriptTag and WAScriptElement. One for tags inside <head> and the other for tags inside <body>.
Cheers Philippe
seaside@lists.squeakfoundation.org