1

I am using jQuery Slider from http://jqueryui.com/slider/ whenever you change a slider i just perform the function without loading the whole page using slider value. For Example I am using slider control to filtering the content. I am using jQuery load to perform the filtering function but looks like slider has disappear after load the content.

Following is the sample code without ajax, I am using ajax everything works without slider. Not sure why jquery load is not load the script or something i missed?

Here is my fiddle http://jsfiddle.net/q5c5T/

Here is my screenshot if i use jquery.load without space this is the error i got enter image description here

HTML

<div class="content">
   This is for testing
    <div class="master">
    </div>
</div>

JS

$( ".master" ).slider({
  value: 60,
  orientation: "horizontal",
  range: "min",
  animate: true,
  change: function(event, ui) {
    //ajax request here
    alert(ui.value);   
    jQuery(".content").load(window.location + " .content");
  }
});
return false;

2 Answers 2

1

The line that make the load contain a space before the dot. Is it better with this line in place?

jQuery(".content").load(window.location + ".content");
Sign up to request clarification or add additional context in comments.

6 Comments

I tested this code without space in my local testing server, i get a error not found. 404 error in console.log with localhost/wordpress/.content if i tried with space it is working as i said the above that same problem appear
OK. Can you clearly explain the goal of your code? Loading a content in a div of the page depending of the slider value, is it this?
Yes i am performing filtering the content based on value of code in my test site. I send that value to my php file via ajax and based on response i filter my content.
Hi I edited my ques see the screenshot i get the error when i tried what you proposing!
Are you sure there is no conflict in javascript versions, plugins, eso? 'cause your JS piece of code seems to be good now.
|
0

Finally I sort out the solution, i am not sure whether it was a correct solution though. I look into the documentation of load jquery but it looks like script not being execute when you call the load function is because of all html, head, script are stripped out and not being executed

So I tried this way whenever i load the data i just find the inline script and append in same element. when i try this it is working

Here is my updated code

                              jQuery('.content').load(window.location + ' .content', function(data) {
                                        var scripts = jQuery(data).find('script');
                                        console.log(scripts);
                                        var length = jQuery(data).find('script').length;
                                        for (var i = 0; i < length; i++) {
                                            var scriptincluder = scripts[0];
                                            jQuery('.content').append(scriptincluder);
}
});

May be this will help some one :)

Thanks, vicks

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.