2011-06-25 15 views
0

私はRaphaelの初心者で、既存の要素からRaphaelオブジェクトを作成する際に問題があります。jqueryを使用してasp.netページ上に要素が見つかりません

以下のコードは、私が試したこととそれぞれのエラーを示しています。理想的には、jqueryを使用して、Raphaelへの最初の呼び出しでオブジェクトを作成したいと考えています。

ご協力いただければ幸いです。

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm2.aspx.cs" Inherits="Fleetstar.UI.WebForm2" %> 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head runat="server"> 
    <script src="js/raphael.js" type="text/javascript"></script> 
    <script src="js/jquery.js" type="text/javascript"></script> 
    <script type="text/javascript"> 
    $(document).ready(function() { 
     var thisWorks = document.getElementById('imgMap');  // This works 
     var thisAlsoWorks = $('.mapClass');   //thsi.works 
     var thisDoeNotWorkA = Raphael(document.getElementById('imgMap'), 200, 200); //Error: Unexpected call to method or property access. 
     var thisDoeNotWorkB = Raphael(document.getElementById('imgMap')[0], 200, 200); //Error: 'tagName' is null or not an object 
     var thisDoeNotWorkC = Raphael(document.getElementById('imgMap').node, 200, 200); //// Error: 'tagName' is null or not an object 
     var thisDoeNotWorkD = Raphael($('.mapClass'), 200, 200);   //Error: 'container' is null or not an object 
     var thisDoeNotWorkE = Raphael($('.mapClass').node, 200, 200); // Error: 'tagName' is null or not an object 
     var thisDoeNotWorkF = Raphael($('.mapClass')[0], 200, 200); //Error: Unexpected call to method or property access. 
     var thisDoeNotWorkG = Raphael($('[id$="imgMap"]'), 200, 200); // Error: 'container' is null or not an object 
     var thisDoeNotWorkH = Raphael($('[id$="imgMap"]')[0], 200, 200); //Error: Unexpected call to method or property access. 
     var thisDoeNotWorkI = Raphael($('[id$="imgMap"]').node, 200, 200); //Error: 'tagName' is null or not an object 

    }); 

</script> 
</head> 
<body> 
    <form id="form1" runat="server"> 
<img class="mapClass" id="imgMap" name="imgMapName" style="position: absolute" src="Images/map.gif" 
    alt="" /> 
</form> 

答えて

1

このお試しください:http://raphaeljs.com/reference.html#Raphael

var thisDoeNotWorkA = Raphael('imgMap', 200, 200); 

スペックを使用すると、ノードIDを渡したいと言います。

EDIT:それがうまくいかない場合、要素IDが別のものによって変更されている可能性がありますか?

0

画像タグから誰かがラファエロのキャンバスを作ろうとしたことは一度もありません。 通常のdivを使用して、好きな場所に配置してみませんか?

thisDoesWork = Raphael(document.getElementById( 'imgMapDiv')、200,200);

チャールズ

http://www.irunmywebsite.com

関連する問題