PDA

View Full Version : jquery in template



crocop21
14 Jun 2012, 8:15 AM
Hi, i was trying to use jquery in template, the questions is for example if in my template i wanna use Jquery but calling from other file where is my function, is possible?:

Function Jquery


$(document).ready(function(){
$('#i_n_f').blur(function() {
alert('Handler for .blur() called.');
});
});
Dataview Template

Ext.define('MyApp.view.MyView', {
extend: 'Ext.view.View',

height: 250,
width: 400,
autoScroll: true,
itemSelector: 'div',
store: 'users',

initComponent: function() {
var me = this;

Ext.applyIf(me, {
tpl: [
'<tpl for="."><div><td><input value="" type="text" id="i_n_f" name="i_n_f" maxlength="12" class="span3"></td></div></tpl>'
]
});

me.callParent(arguments);
}

});

I am calling like this in my APP


<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>ejemtem3</title>

<link rel="stylesheet" type="text/css" href="http://extjs.cachefly.net/ext-4.0.7-commercial/resources/css/ext-all.css"/>
<script type="text/javascript" src="http://extjs.cachefly.net/ext-4.0.7-commercial/ext-all-debug.js"></script>
<script type="text/javascript" src="app.js"></script>

<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>

<script type="text/javascript" src="http://127.0.0.1/myfunction/js_ssep.js"></script>

</head>

scottmartin
14 Jun 2012, 8:46 AM
Here is any article regarding Ext4 and JQuery:
http://loianegroner.com/2011/08/how-to-use-extjs-4-jquery-together/

But I have not tried to use it in a XTemplate before. If the article does not help, perhaps someone can jump in and provide some info to help.

Regards,
Scott.

crocop21
14 Jun 2012, 10:10 AM
I saw this but doesnt help, somebody have some idea?

evant
14 Jun 2012, 3:19 PM
1) You're likely applying it too early, the view isn't created yet

2) It's not really wise to be creating multiple elements with the same id

crocop21
15 Jun 2012, 5:05 AM
Thanks for the answer, and how i can give some property to the view for not be so early, even with one doesn't work, dont know what to do, so manny days trying, somebody have some idea? (:|