I have a problem. Is there a way to change every a href, which has class "primary-action" with "#", and also give it onclick="alert('myalert message');" ?
It can be jQuery or Javascript.
I am realy desperate here. I don't have time to learn javascript for this one thing right now, and realy need help.
Thank you to anyone who can help, or atleast try.
Here is the permanent solution for multiple URLs:
Suppose You have three <a> tags in one page:
test
test
test
Your JQuery Code:
<script type="text/javascript">
$(document).ready(function(){
$('.primary-action').click(function(){
return false;
});
});
</script>
Related
Im try to code this html code for the ember js format, but i cant do it, how can i fix it?
<h5>Thursday. May. 05. 2017</h5>
<div class="progress-bar position" data-percent="48" data-duration="1000" data-color="#6a6f77,#5fb756"><script>$(".progress-bar").loading()</script></div>
I a guessing you are trying to add data-tags
For That you have to add
Ember.LinkComponent.reopen({
attributeBindings: ['data-dismiss']
});
above line to your route file.
And if you want data-percent="48" to be dynamic just change it to data-percent="{{value-from-controller}}".
I could not fully understood your problem , Let me know if this help or you want something else.
link on how you can add data tags
How can I access the text "All changes saved" in the dynamically created Ember script below? I use Protractor to create functional test.
<div class="is-muted">
<script id="metamorph-191-start" type="text/x-placeholder"></script>
<script id="metamorph-191-start" type="text/x-placeholder"></script>
All changes saved
<script id="metamorph-191-end" type="text/x-placeholder"></script>
</div>
Thank you in advance for your help!
I ran into a similar issue earlier and solved it in a rather unelegant manner but it does the job, try the following:
//$$('#metamorph-191-start') will select all the elements on your page with ID metamorph-191-start
//.get(1) will get the second element that passes this requirement aka the script with your text 'all changes saved' in it.
//the .getText().then(function(foo)... gets the text from the element and resolves the promise around it.
$$('#metamorph-191-start').get(1).getText().then(function(foo){
console.log(foo);
});
I said this was unelegant since it is quite the bad practice to use the same ID more than once on a single HTML page.
I'm theming my Wordpress and want to show just number of likes in a fan page. How can I show this
https://api.facebook.com/method/fql.query?format=json&query=select+fan_count+from+page+where+page_id=160397290640478
in my theme? I can't use fopen() function. Maybe javascript? How?
Sorry for this question, but I'm not a programmer.
Sorry, but after all, I got my own answer:
http://pastebin.com/desK1b6D
Thanks!
For reference, when pastebin doesn't work anymore, here's the solution to the problem:
<script>
function showCount(count){
if(count)
document.getElementById('fb_fan_count').innerHTML = count[0].fan_count;
}
</script>
<p id="fb_fan_count"></p>
<script type="text/javascript" src="https://api.facebook.com/method/fql.query?format=json&callback=showCount&query=select+fan_count+from+page+where+page_id%3D16039729064048"></script>
<script type="text/javascript"
src="http://www.domain.com/script.js"></script>
<script type="text/javascript">
function(
123,
"http://www.domain.com",
"http://www.domain.com/videos/video.mp4",
"http://www.domain.com/screengrabs/video.jpg"
);
</script>
I need to isolate the video and the image in this embed code. I'm trying to use regex to accomplish this and I'm a little stuck.
I have--
(?:[^,]*\",){2}
Which matches--
"http://www.domain.com", "http://www.domain.com/videos/video.mp4",
I'm having trouble getting it right. Cheers
\"([^\"]+(videos|screengrabs)[^\"]+)\"
Probably I am too naive to belive that videos and images are always in same folder,
but anyway
videos\/(.*?)".*screengrabs\/(.*?)"
video => $1, image $2
I'm running the developer's Django server while writing a simple view and it seems whenever I request a page, the console shows that there are 2 GETs for the same URL. What would cause this happen? I'm not using any redirects, so I don't see how a 2nd request would be made?
EDIT: It appears to be caused by the template. Changing to a blank html file for a template resolved the issue. The question is why? I have multiple {% if %} {% endif %} sections, with no elses. Could that be an issue?
It also could be Firefox following a WC3 directive under which it's supposed to dual load if certain tags come empty or broken, for example, a without a src="" etc. That being said, I saved off the rendered HTML on receipt and moved it into a static file, where I added the same headers as the real checkout and a small DB log of all accesses.
I just stumble upon this problem and fixed it removing my img wit src=""
Please confirm, if Django is redirecting after appending slash to your url. Its the property APPEND_SLASH in your settings.py controls that.
The second request is probably caused by a mis-configured asset link - a script, style or img tag which is empty or omits the initial / and is therefore re-requesting the page.
It could be your shortcut/favicon
Do you have link rel="shortcut icon" in your page template? Comment it out to see if it removes the second request
In my case : I have the same javascript code in 2 files : one in the base template and the same one in another template. As I use ajax to not reload all the page I got the call 2x, then 4x, and 8x, ...
The solution is the use the javascript code only in mybase.html
Hereafter my js code :
<script type="text/javascript">
// Code jQuery Ici
$(document).ready(function(){
// GET
$(".ajax_onglet_get").click(function(e){
var lien = $(this).attr('href');
$('#zone_travail').fadeOut('fast', function(){
$('#zone_travail').load(lien, function() {
$('#zone_travail').fadeIn('fast');
});
});
e.preventDefault()
});
});