This question already has answers here:
JQuery .prop function not working to uncheck box
(4 answers)
Closed 1 year ago.
I put a checkbox on my webpage, but I want to check it, base on the content of the text file.
I am using the below code:
$(document).ready(function(){
$.ajax({
url : "CH1.txt",
dataType: "text",
success : function (data) {
$("CH1.text").html(data);
var jsonData = JSON.parse(data);
alert(data);
if(data=="1"){$("#CH1CheckBox").prob('checked', true);
else $("#CH1CheckBox").prob('checked', false);
}
});
});
when I remove the below script that belonged to JQuery mobile, everything is ok.
but when I use the JQM it not works.
I already test with the .attr() function as well, but not constructive.
please help.
thanks in advance
You should read the documentation. You need to refresh the element afterwards..
This is how you set the check box:
$("#CH1CheckBox").prop('checked',true).checkboxradio('refresh');
To clear the check box:
$("#CH1CheckBox").prop('checked',false).checkboxradio('refresh');
Related
How to accomplish refreshing the table after $uibModel is closed ?
I am using $uibModel open method to pass the required data to Model.
The data from the Model shown gets saved, but the table does not get refresh.
Any help is greatly appreciated.
Ok, I will try. As far as I understand, you want to save your changes prior to calling the $scope.reloadAttributes();. If that's the case, then just call the modal close in success callback for attributeService.Save() method, like this (copied your code from comments):
$scope.save = function () {
attributeService.Save($scope.attribute)
.then(function (data) {
$log.debug('Saved complete');
$uibModalInstance.close($scope.attribute);
},
function (data) {
$log.debug('Error saving data');
});
}
I don't know what would you like to happen in case attributeService.Save() has failed (close popup? show error?) but it should be clear by now, how to do it.
Hi there, I'm using SpringDataRestAdapter to interact with my spring data rest api. From the screen shot you can see that I've just loaded all the questions and I'm attempting to load their answers (one-to-many) relationship. In the debug window the _embeddedItems array is an array of Questions with _links to each questions answers. I'm trying to prompt SpringDataRestAdapter to autoload the answers by passing 'answers' as an argument to the processWithPromise call but to no avail.
The urls look like
http://localhost:8080/api/questions
http://localhost:8080/api/question/1/answers
The Question.loadAnswers(question) call is commented out... It works in that it loads the question's answers but I felt I was using the framework incorrectly.
Here is the method
Question.loadAnswers = function (question) {
question.answers = question.answers? question.answers : [];
angular.forEach(question._links.answers, function (answerLink) {
var deferred = $http.get(answerLink);
return SpringDataRestAdapter.processWithPromise(deferred).then(function (data) {
question.answers = data._embeddedItems;
});
});
};
Thanks,
Mark.
please have a look at this answer on the corresponding Github issue here https://github.com/guylabs/angular-spring-data-rest/issues/22.
Thanks and regards,
Guy
I'm using CamanJS to add some image processing features to my website, it's a simple and great library but still its documentation is somehow poor.
I'm uploading an image to my website, then I'm applying all the effects on the image uploaded (it's not saved on the Server, I'm modifying it on the client side).
as shown on the official website (http://camanjs.com/guides/#BasicUsage):
function invertColors() {
Caman("#original-img", function () {
this.invert().render();
});
}
The problem is when I re-upload a new image. apparently CamanJS keeps the first image cashed, and the new image is not shown.
when I read about this issue the only place I found an answer for this is here:
CamanJS - change underlying canvas after applying filters/manipulations
but I'm sorry the answer was not that clear for me. so I have to ask it again.
the answer suggested to use reloadCanvasData() but I didn't know exactly how to use it, I tried so many ways but all went in vain!
I tried:
Caman("#original-img", function () {
this.reloadCanvasData();
});
and:
Caman.reloadCanvasData();
etc.
Can anyone provide a working example?
Thanks
I thought I'd help those who came here looking at how to replace PIXEL data rather than just a loaded image:
can1 = document.getElementById("MyCanvas1");
ctx1 = can1.getContext("2d");
var c = <do what ever you need and make a new canvas here>
ctx1.putImageData(c, 0,0); // <---this replaces the pixeldata
Caman("#MyCanvas1", function () {
this.render();
});
This way you can process the image at the pixel level, and then get it back into camanjs.
As a solution what I have done is clear the canvas and have again Inserted an HTML Image tag. before calling Second Image.with camanjs
something like following
function clearCanvas() {
$('#ImageParentDiv').empty();
var htmlTag = '<img src="../images/Loading.gif" id="original-img">';
$('#ImageParentDiv').html(htmlTag);
}
Just call the revert() when you need an original image:
Caman("#original-img", function () {
this.revert();
this.render();
});
Is there a way to click on a hidden value in a sub menu. I would like to be able to do something like
driver.findElement(protractor.By.xpath('/html/body/div/div/a')).mouseover.then(function() {
ptor.findElement(protractor.By.className('name').getText().then(function(result) {
expect(result).toBe('Me');
});
});
when the menu item is not visible, or are we limited with this at the moment. If this is not possible is there a way around this issue at present.
ok so after a long and painful search trying to find an answer to this question I finally came across the answer trying to answer a different question.
Most of the documentation I found explain that we must use Actions in the form of a WebElement and then cast that to Javascript and pass it a script element in the form of an array with the click action.
Well the same kinds goes here but with a few modifications.
describe('', function() {
var ptor = protractor.getInstance();
var driver = ptor.driver;
it('', function() {
var hiddenElement = driver.findElement(protractor.By.yourchosenlocator(''));
driver.executeScript("arguments[0].click()", hiddenElement).then(function() {
expect(whatever).toMatch(whatever);
});
}, 30000);
});
as you can see there is no use of webelement and no cast required.
Here are the sources that helped me in my search for answers
How do you click on an element which is hidden using Selenium Webdriver?
SELENIUM WEBDRIVER – HOW TO CLICK ON A HIDDEN LINK OR MENU
Selenium WebDriver - hidden select and anchor [duplicate]
Just to add on to the accepted answer, the below code worked for me.
Import statement:
import { browser, by, element } from 'protractor';
Code:
const hiddenElement = element(by.id('hiddenIcon'));
browser.driver.executeScript('arguments[0].click();', hiddenElement.getWebElement());
Just change the hiddenIcon to the id of your element.
Instead of using
var ptor = protractor.getInstance(); var driver = ptor.driver;
we can also use
browser.driver
I created Extjs.Panel and now I would like to dynamically load a content to it. So I wrote this simple code
Ext.get('contentPanel').load({
url: '#Url.Action("TempView","Home")'
});
After executing this function, panel is populated with TempView, however couple of seconds later I get an error in Extjs library
Microsoft JScript runtime error:Unable to get value of the property
'events': object is null or undefined.
EDIT
I flollowed #DmitryB advice and I used debug version of library. Here is what I found out. It turned out that the problem is in function
getElementEventCache
which is defined in file ext-all-debug.js in line 11108. The function looks this way
getElementEventCache : function(element) {
if (!element) {
return {};
}
var elementCache = Ext.cache[this.getId(element)];
return elementCache.events || (elementCache.events = {});
},
The exception is thrown in the last line, because of the fact that elementCache is null.
Here is the stacktrace from visualstudio
I had a very similar error that was resolved by adding the following line. (from this forum thread)
if(Ext.isIE) {
Ext.enableGarbageCollector=false;
}
I'm using bellow code and work cool. This may help you.
Try this
var content_div = Ext.get(div_id);
content_div.load({
url:your_url,params:{id:'abc'},scripts:true,text: 'Loading...'});
content_div.show();