开发者

problem with jquerytools expose in Play! tutorial

I was trying out the Play! framework tutorial's post comment portion ,where jquery tools' expose function is used to bring focus to the textfields .I am using jquery-1.5.2.min.js and jquery.tools-1.2.5.toolbox.expose.min.js

I tried the page in firefox and chrome.But ,the focus effect doesn't happen.

when I used the chrome's inspect element / Resources tab and checked the Scripts,I found these errors.

    Uncaught SyntaxError: Unexpected token < jquery.tools.1.2.5.toolbox.min.js:1
    Uncaught TypeError: Object [object Object] has no method 'expose'    postcomment:94
    (anonymous function)    postcomment:94
    d.extend._Deferred.f.resolveWithjquery-1.5.2.min.js:16
    d.d.extend.readyjquery-1.5.2.min.js:16
    d.c.addEventListener.yjquery-1.5.2.min.js:16

In the Scripts tab,only the jquery-1.5.2.min.js is shown, but not the jquery.tools-1.2.5.toolbox.expose.min.js file.

When mozilla firefox was used,the firebug cosole reports 2 errors

syntax error
[Break on this error] <!DOCTYPE html>\n  jquery.t...se.min.js (line 1)

$("form").expose is not a function
anonymous()postcomm...?postId=3 (line 97)

anonymous(Document postcomment?postId=3, [function()])jquery-1....2.min.js (line 16)

anonymous(Object name=a)jquery-1....2.min.js (line 16)

anonymous()jquery-1....2.min.js (line 16)

[Break on this error] $('form').expose({api: true, loadSpeed: 0}).load(); \npostcomm...?postId=3 (line 97

Copy Error gives

$("form").expose is not a function
http://localhost:9000/application/postcomment?postId=3
Line 97

here is the portion of main.html where .js files are added

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
    <head>
        <title>#{get 'title' /}</title>
        <meta charset="${_response_encoding}">
        <link rel="stylesheet" media="screen" href="@{'/public/stylesheets/main.css'}">
        #{get 'moreStyles' /}
开发者_开发问答        <link rel="shortcut icon" type="image/png" href="@{'/public/images/favicon.png'}">
        <script src="@{'/public/javascripts/jquery-1.5.2.min.js'}" ></script>
        <script src="@{'/public/javascripts/jquery.tools-1.2.5.toolbox.expose.min.js'}"></script>
        #{get 'moreScripts' /}
    </head>
    <body>
...

and the show.html where the expose function is called

#{extends 'main.html'/}
#{set title:post.title /}
...
<script type="text/javascript" charset="utf-8">
    $(function() {         
        // Expose the form 
        $('form').click(function() { 
            $('form').expose({api: true}).load(); 
        }); 

        // If there is an error, focus to form
        if($('form .error').size()) {
            $('form').expose({api: true, loadSpeed: 0}).load(); 
            $('form input[type=text]').get(0).focus();
        }
    });
</script>

Can someone help me correct this?


How does the actual mark-up (HTML) look in Firebug?

syntax error
[Break on this error] <!DOCTYPE html>\n  jquery.t...se.min.js (line 1)

Seems to be invalid invalid mark-up, although I can't see where that comes from, the views look fine. And did you check that /public/javascripts/jquery.tools-1.2.5.toolbox.expose.min.js really exists in your project?


okay,finally found it.. I got the jquery tools javascript file from the link in the tutorial which points to tutorial's jquery tools link It is corrupted and contains a <!DOCTYPE html> element at the beginning..This causes error..It never occurred to me to look inside the javascript file until I read maenu's reply..Thanks to him..

The expose effect works when I used the .js file from flowplayer.org site

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜