I'm using the tapestry ZoneRefresh mixins to update zone periodically.
<t:zone t:id="zoneInf" t:mixins="zonerefresh" t:period="4" t:update="show">
<t:if test="ready">
success & How to stop refreshing
<p:else>
Loading...
</p:else>
</t:if>
</t:zone>
My question is: How to stop the refresh? Is this possible?
It sounds like you might have to write your own mixin. But it is very little code. Take a look at http://jumpstart.doublenegative.com.au/jumpstart/examples/ajax/periodicupdatemixin and http://tapestry5-jquery.com/mixins/docszonerefresh
Related
Firstly, Karate UI automation is really awesome tool. I am kind of enjoying it while writing the UI tests using Karate. I ran into a situation where in, i was trying to fetch the shadowRoot elements. I read few similar posts related to javascript executor with karate and learnt that it is already answered. it is recommended to use driver.eval. But in Karate 0.9.5 there is no eval, it has script() or scriptAll(). I have gone through documentation couple of times to figure out how i can fetch element inside an element but no luck.
Using traditional selenium+java, we can fetch shadowRoot like this way:
something like shadowRoot which sits inside a parent element like div or body.
//downloads-manager is the tagname and under that downloads-manager, a shadowRoot element exists
The HTML looks like this. it is from chrome://downloads.
<downloads-manager>
#shadow-root(open)
</download-manager>
WebElement downloadManager =driver.findElement(By.tagName("downloads-manager");
WebElement shadowRoot= (WebElement)((JavaScriptExecutor)driver)
.executeScript("return arguments[0].shadowRoot",downloadManager);
So i tried the following in Karate UI
script("downloads-manager","return _.shadowRoot"); //js injection error
script('downloads-manager', "function(e){ return e.shadowRoot;}"); // same injection error as mentioned above.
def shadowRoot = locate("downloads-manager").script("function(e){return e.shadowRoot};"); //returns an empty string.
I bet there is a way to get this shadowRoot element using Karate UI but i am kind of running out of options and not able to figure out this.
Can someone please look into this & help me?
-San
Can you switch to XPath and see if that helps:
* def temp = script('//downloads-manager', '_.innerHTML')
Else please submit a sample in this format so we can debug: https://github.com/intuit/karate/tree/develop/examples/ui-test
EDIT: after you posted the link to that hangouts example in the comments, I figured out the JS that would work:
* driver 'http://html5-demos.appspot.com/hangouts'
* waitFor('#hangouts')
* def heading = script('hangout-module', "_.shadowRoot.querySelector('h1').textContent")
* match heading == 'Paul Irish'
It took some trial and error and fiddling with the DevTools console to figure this out. So the good news is that it is possible, you can use any JS you need, and you do need to know which HTML element to call .shadowRoot on.
EDIT: for other examples of JS in Karate: https://stackoverflow.com/a/60800181/143475
I add the same ImperativeExpression to DirectToolItem and DirectMenuItem, but my #Evaluate method in class for expression was called only for DirectMenuItem. So I can't manage the visibility of DirectToolItem by ImperativeExpression. This is bug or I need to send some event to update visibility? Something like UIEvents.REQUEST_ENABLEMENT_UPDATE_TOPIC?
Unfortunately the visible-when expression for a tool item does not currently work at all. Eclipse bug 494663 describes the problem.
I'm very new to CoffeScript and want to edit some code that I found. Right now, it runs this function right when the DOM is loaded:
jQuery ->
$('#s3-uploader').S3Uploader
How can I rewrite it such that it only runs after the page is loaded? I need to wait so I can get the correct instance variables:
(on page load) ->
$('#s3-uploader').S3Uploader
additional_data: {project_id: #project.id, step_id: #step.id, user_id: current_user.id}
This is quite an old question, and no doubt you have found a solution already. But for the benefit of anyone coming here from Google....
It is also not 100% clear from your question, but you appear to be using a framework such as Ruby on Rails.
If so, then the correct answer of course is that you should not be accessing instance variables from Coffeescript. Coffeescript files in the asset pipeline are compiled during deployment, and have no knowledge of the controller or instance variables.
The correct way is to assign these variables to data attributes in the DOM, and then reference the data attributes.
#view.html.erb
<div id="uploader" data-project_id="<%= #project.id %>" ></div>
#script.coffee.js
(on page load) ->
$('#s3-uploader').S3Uploader
additional_data: {project_id: $('#uploader').data('project_id') .... }
For rails, this worked for me when all the other answers here did not:
$(document).on "turbolinks:load", ->
You're looking for $(document).ready event handler.
$(document).ready ->
$('#s3-uploader').S3Uploader
checkVariable = ->
if variableLoaded == true
# here is your next action
else
return
setTimeout 'checkVariable()', 1000
I want to provide a way to use an on-event handler from the outside of a plugin. Problem is, that the trigger will not fired if I provide them in wrong order.
For example, this works:
$(window).on('foo:bar', function(){
alert(true);
});
$(window).trigger('foo:bar');
...this, however does not:
$(window).trigger('foo:bar');
$(window).on('foo:bar', function(){
alert(true);
});
Any ideas how the second approach can work?
Update
Here it works: http://www.benplum.com/projects/rubberband/
You cannot. You want to eat cake before baking it.
UPD: You're misinterpreting the code at http://www.benplum.com/projects/rubberband/
Here is a jsfiddle with proof that it doesn't work like you're thinking: jsfiddle.net/zerkms/z5Mya/
Note about code: I've forked the library and added trivial console.log here: https://github.com/zerkms/Rubberband/blob/master/jquery.bp.rubberband.js#L77
I have been sitting with a problem for quite a while now and I just can't seem to find what I'm missing.
I have written a custom trace listener component for Enterprise Library 5.0 for the Logging application block which works but the configured ILogFormatter just won't resolve and so I always end up with the basic string text when it gets handled by my component.
I saw in the enterprise library source code that they use the "Container.ResolvedIfNotNull()" method. It doesn't seem to work for me. I need it to write out a custom formatted string for my component to use. You know, not just the message but the timestamp, machinename, threadId, etc.
Does anyone have any ideas on how to fix this?
Thanks in advance.
Like I've mentioned on this site: http://entlib.codeplex.com/discussions/261749
When you create your CreationExpression in the TraceListener data class make sure you have a flat constructor definition. To put it in other words, don't return:
() => new MyTraceListener(new TraceListenerConfig(..., Container.ResolvedIfNotNull<ILogFormatter>(), ...));
just have it in the constructor of the MyTraceListener:
() => new MyTraceListener(..., Container.ResolvedIfNotNull<ILogFormatter>(), ...);